Skip to content

Commit

Permalink
COM-3518 : add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Manon Palin committed Feb 22, 2024
1 parent 9c175b4 commit f6f0ced
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions tests/integration/courses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,23 @@ describe('COURSES ROUTES - PUT /courses/{_id}', () => {
expect(course).toEqual(1);
});

it('should remove the course trainer who is contact', async () => {
const payload = { trainer: '', contact: '' };

const response = await app.inject({
method: 'PUT',
url: `/courses/${coursesList[17]._id}`,
headers: { Cookie: `alenvi_token=${authToken}` },
payload,
});

expect(response.statusCode).toBe(200);

const courseUpdated = await Course
.countDocuments({ _id: coursesList[17]._id, contact: { $exists: false }, trainer: { $exists: false } });
expect(courseUpdated).toEqual(1);
});

it('should return 400 if try to remove estimated start date', async () => {
const payload = { estimatedStartDate: '' };
const response = await app.inject({
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/seed/coursesSeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ const coursesList = [
{ // 17 Intra course without slots
_id: new ObjectId(),
subProgram: subProgramsList[0]._id,
contact: vendorAdmin._id,
contact: trainer._id,
companies: [authCompany._id],
misc: 'third session',
trainer: trainer._id,
Expand Down

0 comments on commit f6f0ced

Please sign in to comment.