diff --git a/__tests__/routes/userRoutes.spec.js b/__tests__/routes/userRoutes.spec.js index 5ab0ea7d..ddb66634 100644 --- a/__tests__/routes/userRoutes.spec.js +++ b/__tests__/routes/userRoutes.spec.js @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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'); @@ -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); diff --git a/__tests__/setup/globalConfigMongo.json b/__tests__/setup/globalConfigMongo.json index 541fc6e6..bb119bc2 100644 --- a/__tests__/setup/globalConfigMongo.json +++ b/__tests__/setup/globalConfigMongo.json @@ -1 +1 @@ -{"mongoDBName":"jest","mongoUri":"mongodb://127.0.0.1:53962/"} \ No newline at end of file +{"mongoDBName":"jest","mongoUri":"mongodb://127.0.0.1:55698/"} \ No newline at end of file diff --git a/routes/userRoutes.js b/routes/userRoutes.js index 42b03a75..dff808b0 100644 --- a/routes/userRoutes.js +++ b/routes/userRoutes.js @@ -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;