From f034d6fd2e8ce299644daac6947dd4703b1ca4a3 Mon Sep 17 00:00:00 2001 From: aelassas Date: Wed, 21 Feb 2024 08:31:40 +0100 Subject: [PATCH] Update location.test.ts --- api/coverage/cobertura-coverage.xml | 130 ++++++++++++++-------------- api/tests/location.test.ts | 25 ++++-- 2 files changed, 83 insertions(+), 72 deletions(-) diff --git a/api/coverage/cobertura-coverage.xml b/api/coverage/cobertura-coverage.xml index 89fcd6da5..088c75c35 100644 --- a/api/coverage/cobertura-coverage.xml +++ b/api/coverage/cobertura-coverage.xml @@ -1,6 +1,6 @@ - + C:\dev\bookcars\src\api @@ -96,9 +96,9 @@ - + - + @@ -116,14 +116,14 @@ - + - + - + - + @@ -141,10 +141,10 @@ - - - - + + + + @@ -152,8 +152,8 @@ - - + + @@ -289,7 +289,7 @@ - + @@ -982,7 +982,7 @@ - + @@ -994,9 +994,9 @@ - + - + @@ -1004,14 +1004,14 @@ - + - + - + - + @@ -1053,10 +1053,10 @@ - - - - + + + + @@ -1068,31 +1068,31 @@ - - + + - - - - - - - + + + + + + + - - - - + + + + - - + + @@ -1273,9 +1273,9 @@ - + - + @@ -1359,8 +1359,8 @@ - - + + @@ -1977,44 +1977,44 @@ - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + @@ -2432,14 +2432,14 @@ - + - + - + - + @@ -2519,8 +2519,8 @@ - - + + diff --git a/api/tests/location.test.ts b/api/tests/location.test.ts index 67db748b8..e9a379f97 100644 --- a/api/tests/location.test.ts +++ b/api/tests/location.test.ts @@ -119,14 +119,19 @@ describe('PUT /api/update-location/:id', () => { }, ] - const res = await request(app) + let res = await request(app) .put(`/api/update-location/${LOCATION_ID}`) .set(env.X_ACCESS_TOKEN, token) .send(LOCATION_NAMES) - expect(res.statusCode).toBe(200) expect(res.body.values?.length).toBe(3) + res = await request(app) + .put(`/api/update-location/${TestHelper.GetRandromObjectIdAsString()}`) + .set(env.X_ACCESS_TOKEN, token) + .send(LOCATION_NAMES) + expect(res.statusCode).toBe(204) + await TestHelper.signout(token) }) }) @@ -135,11 +140,14 @@ describe('GET /api/location/:id/:language', () => { it('should get a location', async () => { const language = 'en' - const res = await request(app) + let res = await request(app) .get(`/api/location/${LOCATION_ID}/${language}`) - expect(res.statusCode).toBe(200) expect(res.body?.name).toBe(LOCATION_NAMES.filter((v) => v.language === language)[0].name) + + res = await request(app) + .get(`/api/location/${TestHelper.GetRandromObjectIdAsString()}/${language}`) + expect(res.statusCode).toBe(204) }) }) @@ -213,15 +221,18 @@ describe('DELETE /api/delete-location/:id', () => { let location = await Location.findById(LOCATION_ID) expect(location).not.toBeNull() - const res = await request(app) + let res = await request(app) .delete(`/api/delete-location/${LOCATION_ID}`) .set(env.X_ACCESS_TOKEN, token) - expect(res.statusCode).toBe(200) - location = await Location.findById(LOCATION_ID) expect(location).toBeNull() + res = await request(app) + .delete(`/api/delete-location/${LOCATION_ID}`) + .set(env.X_ACCESS_TOKEN, token) + expect(res.statusCode).toBe(204) + await TestHelper.signout(token) }) })