diff --git a/apps/backend/__tests__/auth/test-auth.js b/apps/backend/__tests__/auth/test-auth.js index dbc143d9..aa72c35c 100644 --- a/apps/backend/__tests__/auth/test-auth.js +++ b/apps/backend/__tests__/auth/test-auth.js @@ -120,7 +120,7 @@ describe('Test authentication ', () => { let updatedData = await mongoose .model(STEP_KEY) - .findOne({ _id: mongoose.Types.ObjectId(patientID) }); + .findOne({ _id: new mongoose.Types.ObjectId(patientID) }); updatedData = updatedData.toObject(); updatedData._id = updatedData._id.toString(); diff --git a/apps/backend/__tests__/mock-data/patients-mock-data.js b/apps/backend/__tests__/mock-data/patients-mock-data.js index 18dad270..219c4a2d 100644 --- a/apps/backend/__tests__/mock-data/patients-mock-data.js +++ b/apps/backend/__tests__/mock-data/patients-mock-data.js @@ -20,7 +20,7 @@ module.exports.POST_PATIENT_MINIMAL_REQUEST = { }; module.exports.POST_IMMUTABLE_PATIENT_DATA = { - _id: mongoose.Types.ObjectId(), + _id: new mongoose.Types.ObjectId(), lastEdited: new Date('2000-12-02T01:17:55.181Z'), lastEditedBy: 'Tickle Me Elmo', __v: 1, @@ -76,8 +76,8 @@ module.exports.DEFAULT_STEP_DATA = { }; module.exports.POST_IMMUTABLE_STEP_DATA = { - _id: mongoose.Types.ObjectId(), - patientId: mongoose.Types.ObjectId(), + _id: new mongoose.Types.ObjectId(), + patientId: new mongoose.Types.ObjectId(), lastEdited: new Date('2000-12-02T01:17:55.181Z'), lastEditedBy: 'Tickle Me Elmo', __v: 1, diff --git a/apps/backend/__tests__/routes/patients/test-patients-id.js b/apps/backend/__tests__/routes/patients/test-patients-id.js index b7bc4691..96bc453d 100644 --- a/apps/backend/__tests__/routes/patients/test-patients-id.js +++ b/apps/backend/__tests__/routes/patients/test-patients-id.js @@ -61,7 +61,7 @@ describe('PUT /patients/:id', () => { // Query for ids must be done as an ObjectId let updatedData = await mongoose .model(STEP_KEY) - .findOne({ _id: mongoose.Types.ObjectId(patientID) }); + .findOne({ _id: new mongoose.Types.ObjectId(patientID) }); updatedData = updatedData.toObject(); updatedData._id = updatedData._id.toString(); @@ -90,7 +90,7 @@ describe('PUT /patients/:id', () => { let updatedData = await mongoose .model(STEP_KEY) - .findOne({ _id: mongoose.Types.ObjectId(patientID) }); + .findOne({ _id: new mongoose.Types.ObjectId(patientID) }); updatedData = updatedData.toObject(); updatedData._id = updatedData._id.toString(); expectStrictEqualWithTimestampOrdering( diff --git a/apps/backend/__tests__/routes/patients/test-put-patients-id.js b/apps/backend/__tests__/routes/patients/test-put-patients-id.js index 0bedd8b1..8d909ac9 100644 --- a/apps/backend/__tests__/routes/patients/test-put-patients-id.js +++ b/apps/backend/__tests__/routes/patients/test-put-patients-id.js @@ -103,7 +103,7 @@ describe('PUT /patients/:id', () => { const getPatientFromDB = async () => { const result = await models.Patient.findOne({ - _id: mongoose.Types.ObjectId(PATIENT_ID), + _id: new mongoose.Types.ObjectId(PATIENT_ID), }); return result.toObject(); }; diff --git a/apps/backend/__tests__/routes/roles/test-put-roles-roleid.js b/apps/backend/__tests__/routes/roles/test-put-roles-roleid.js index 4ff99756..d977cc29 100644 --- a/apps/backend/__tests__/routes/roles/test-put-roles-roleid.js +++ b/apps/backend/__tests__/routes/roles/test-put-roles-roleid.js @@ -88,7 +88,7 @@ describe('PUT /roles/:roleid', () => { const getRoleFromDB = async (roleId) => { const result = await models.Role.findOne({ - _id: mongoose.Types.ObjectId(roleId), + _id: new mongoose.Types.ObjectId(roleId), }); return result.toObject(); }; diff --git a/scripts/generate-db-data.js b/scripts/generate-db-data.js index 9260b5e3..7781acd1 100644 --- a/scripts/generate-db-data.js +++ b/scripts/generate-db-data.js @@ -36,7 +36,7 @@ const generatePatients = (numPatients) => { const generatePatient = () => { const patient = {}; patient.firstName = faker.name.firstName(); - patient._id = mongoose.Types.ObjectId(); + patient._id = new mongoose.Types.ObjectId(); if (getRandomInt(2)) patient.fathersName = faker.name.firstName();