Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/backend/__tests__/auth/test-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions apps/backend/__tests__/mock-data/patients-mock-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/__tests__/routes/patients/test-patients-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-db-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down