Skip to content

Commit

Permalink
wopsi, route fix in all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiiagran committed Oct 13, 2023
1 parent d44a98a commit 236b12b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions __tests__/routes/userRoutes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe('Users Routes', () => {
expect(updatedUser.subscriptions.find((element) => element == courseId));

const response = await request(`http://localhost:${PORT}`)
.get('/api/users?user_id=' + userId + '&course_id=' + courseId);
.get('/api/users/subscriptions?user_id=' + userId + '&course_id=' + courseId);

expect(response.status).toBe(200);
expect(response.text).toBe('true');
Expand All @@ -264,7 +264,7 @@ describe('Users Routes', () => {
const userId = user._id;

const response = await request(`http://localhost:${PORT}`)
.get('/api/users?user_id=' + userId + '&course_id=' + courseId);
.get('/api/users/subscriptions?user_id=' + userId + '&course_id=' + courseId);

expect(response.status).toBe(200);
expect(response.text).toBe('false');
Expand All @@ -282,7 +282,7 @@ describe('Users Routes', () => {

// simulate a request for a non-existent user
const response = await request(`http://localhost:${PORT}`)
.get('/api/users?user_id=' + userId + '&course_id=' + courseId);
.get('/api/users/subscriptions?user_id=' + userId + '&course_id=' + courseId);

expect(response.status).toBe(404);
expect(response.body.error.code).toBe('E0004');
Expand All @@ -296,7 +296,7 @@ describe('Users Routes', () => {

// simulate a request with invalid user id
const response = await request(`http://localhost:${PORT}`)
.get('/api/users?user_id=this-is-an-invalid-userId&course_id=' + courseId);
.get('/api/users/subscriptions?user_id=this-is-an-invalid-userId&course_id=' + courseId);

expect(response.status).toBe(500);
expect(response.body.error.code).toBe('E0003');
Expand All @@ -313,7 +313,7 @@ describe('Users Routes', () => {

// simulate a request for a non-existent course
const response = await request(`http://localhost:${PORT}`)
.get('/api/users?user_id=' + userId + '&course_id=' + courseId);
.get('/api/users/subscriptions?user_id=' + userId + '&course_id=' + courseId);

expect(response.status).toBe(404);
expect(response.body.error.code).toBe('E0006');
Expand All @@ -327,7 +327,7 @@ describe('Users Routes', () => {

// simulate a request with invalid course id
const response = await request(`http://localhost:${PORT}`)
.get('/api/users/subscriptions/?user_id=' + userId + '&course_id=this-is-an-invalid-courseId');
.get('/api/users/subscriptions?user_id=' + userId + '&course_id=this-is-an-invalid-courseId');


expect(response.status).toBe(500);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/setup/globalConfigMongo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"mongoDBName":"jest","mongoUri":"mongodb://127.0.0.1:53962/"}
{"mongoDBName":"jest","mongoUri":"mongodb://127.0.0.1:55698/"}
2 changes: 1 addition & 1 deletion routes/userRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ router.get('/:id/subscriptions', async (req, res) => {


// Checks if user is subscribed to a specific course
router.get('/subscriptions/', async (req, res) => {
router.get('/subscriptions', async (req, res) => {
try {
const { user_id, course_id } = req.query;

Expand Down

0 comments on commit 236b12b

Please sign in to comment.