From a68aa861e127381ab90617bbdabe0d55b79ebbbb Mon Sep 17 00:00:00 2001 From: Ludovic Date: Wed, 3 May 2023 15:59:28 +0200 Subject: [PATCH] fix: change test --- api/__tests__/routes/region.test.ts | 76 +++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 4 deletions(-) diff --git a/api/__tests__/routes/region.test.ts b/api/__tests__/routes/region.test.ts index 114516bd1..6db3ea57f 100644 --- a/api/__tests__/routes/region.test.ts +++ b/api/__tests__/routes/region.test.ts @@ -176,6 +176,75 @@ describe("Region tests", () => { }); }); + //TODO: fix, voor admin + // test("SOFT DELETE /region/:id", async () => { + // const regionSoft = { + // hardDelete: false, + // }; + // await runner.delete({ url: "/region/3", data: regionSoft }); + + // // verify that the region is truly deleted + // const expected = [ + // { + // deleted: false, + // id: 1, + // name: "Region 1", + // users: [ + // { + // id: 1, + // region_id: 1, + // user: { + // address_id: 1, + // admin: false, + // date_added: "2023-05-04T12:00:00.000Z", + // deleted: false, + // email: "student@trottoir.be", + // first_name: "Dirk", + // id: 1, + // last_login: "2023-05-04T12:00:00.000Z", + // last_name: "De Student", + // phone: "0123456789", + // student: true, + // super_student: false, + // }, + // user_id: 1, + // }, + // ], + // }, + // { + // deleted: false, + // id: 2, + // name: "Region 2", + // users: [ + // { + // id: 2, + // region_id: 2, + // user: { + // address_id: 2, + // admin: false, + // date_added: "2023-05-04T12:00:00.000Z", + // deleted: false, + // email: "superstudent@trottoir.be", + // first_name: "Toon", + // id: 2, + // last_login: "2023-05-04T12:00:00.000Z", + // last_name: "De Superstudent", + // phone: "9876543210", + // student: false, + // super_student: true, + // }, + // user_id: 2, + // }, + // ], + // }, + // { deleted: true, id: 3, name: "Region 3", users: [] }, + // ]; + // await runner.get({ + // url: "/region?deleted=true", + // expectedData: expected, + // }); + // }); + afterAll(() => { app.close(); }); @@ -293,9 +362,7 @@ describe("Region tests", () => { expectedData: [notFoundResponse], statusCode: 404, }); - }); - test("Find a nonexistent region", async () => { await runner.get({ url: "/region/-1", expectedData: [notFoundResponse], @@ -304,9 +371,10 @@ describe("Region tests", () => { }); test("Update a nonexistent region", async () => { - await runner.get({ + await runner.patch({ url: "/region/0", - expectedData: [notFoundResponse], + data: newRegion, + expectedResponse: notFoundResponse, statusCode: 404, }); });