From cfb47135b572515a7a8dc080944f460e97fcfadd Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Sun, 26 Apr 2026 14:18:55 +0200 Subject: [PATCH] style: fix deno fmt and lint --- tests/e2e/modules_test.ts | 10 ++++++++-- tests/integration/modules_test.ts | 10 ++++++++-- tests/unit/modules_test.ts | 32 +++++++++++++++++++++++++------ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/tests/e2e/modules_test.ts b/tests/e2e/modules_test.ts index bc8f1c8..21faee7 100644 --- a/tests/e2e/modules_test.ts +++ b/tests/e2e/modules_test.ts @@ -17,8 +17,14 @@ Deno.test({ name: "e2e modules: GET /modules returns all as employee", async fn() { await truncateAll(); - await seedModules([{ id: "MATH101", nom: "Mathématiques" }, { id: "INFO101", nom: "Informatique" }]); - const res = await modulesHandler.GET!(makeGetRequest("/modules"), makeEmployeeContext()); + await seedModules([{ id: "MATH101", nom: "Mathématiques" }, { + id: "INFO101", + nom: "Informatique", + }]); + const res = await modulesHandler.GET!( + makeGetRequest("/modules"), + makeEmployeeContext(), + ); assertEquals(res.status, 200); const body = await res.json(); assertEquals(body.length, 2); diff --git a/tests/integration/modules_test.ts b/tests/integration/modules_test.ts index f0acc7f..df32fba 100644 --- a/tests/integration/modules_test.ts +++ b/tests/integration/modules_test.ts @@ -9,7 +9,10 @@ Deno.test({ name: "integration modules: list all modules", async fn() { await truncateAll(); - await seedModules([{ id: "MATH101", nom: "Mathématiques" }, { id: "INFO101", nom: "Informatique" }]); + await seedModules([{ id: "MATH101", nom: "Mathématiques" }, { + id: "INFO101", + nom: "Informatique", + }]); const rows = await testDb.select().from(modules); assertEquals(rows.length, 2); }, @@ -21,7 +24,10 @@ Deno.test({ name: "integration modules: create and retrieve by id", async fn() { await truncateAll(); - const [created] = await testDb.insert(modules).values({ id: "PHYS101", nom: "Physique" }).returning(); + const [created] = await testDb.insert(modules).values({ + id: "PHYS101", + nom: "Physique", + }).returning(); assertExists(created); assertEquals(created.id, "PHYS101"); diff --git a/tests/unit/modules_test.ts b/tests/unit/modules_test.ts index c9f2276..e94cdc4 100644 --- a/tests/unit/modules_test.ts +++ b/tests/unit/modules_test.ts @@ -42,7 +42,12 @@ Deno.test("mock API: GET /modules/:id returns one module", async () => { }); Deno.test("mock API: GET /modules/:id 404 when not found", async () => { - mockFetch({ "/modules/UNKNOWN": { status: 404, body: { error: "Ressource introuvable" } } }); + mockFetch({ + "/modules/UNKNOWN": { + status: 404, + body: { error: "Ressource introuvable" }, + }, + }); try { const res = await fetch("http://localhost/api/modules/UNKNOWN"); assertEquals(res.status, 404); @@ -69,7 +74,13 @@ Deno.test("mock API: POST /modules creates module (201)", async () => { }); Deno.test("mock API: POST /modules 409 on duplicate id", async () => { - mockFetch({ "/modules": { method: "POST", status: 409, body: { error: "Un module avec cet identifiant existe déjà" } } }); + mockFetch({ + "/modules": { + method: "POST", + status: 409, + body: { error: "Un module avec cet identifiant existe déjà" }, + }, + }); try { const res = await fetch("http://localhost/api/modules", { method: "POST", @@ -98,7 +109,9 @@ Deno.test("mock API: POST /modules 400 on missing fields", async () => { Deno.test("mock API: PUT /modules/:id updates nom", async () => { const updated: Module = { id: "JIN702C", nom: "Optimisation avancée" }; - mockFetch({ "/modules/JIN702C": { method: "PUT", status: 200, body: updated } }); + mockFetch({ + "/modules/JIN702C": { method: "PUT", status: 200, body: updated }, + }); try { const res = await fetch("http://localhost/api/modules/JIN702C", { method: "PUT", @@ -116,7 +129,9 @@ Deno.test("mock API: PUT /modules/:id updates nom", async () => { Deno.test("mock API: DELETE /modules/:id returns 204", async () => { mockFetch({ "/modules/JIN702C": { method: "DELETE", status: 204 } }); try { - const res = await fetch("http://localhost/api/modules/JIN702C", { method: "DELETE" }); + const res = await fetch("http://localhost/api/modules/JIN702C", { + method: "DELETE", + }); assertEquals(res.status, 204); } finally { restoreFetch(); @@ -140,8 +155,13 @@ Deno.test("mock DB: insert module", () => { Deno.test("mock DB: update module nom", () => { const db = createMockDb({ tables: { modules: [...modules] } }); - db.updateWhere("modules", (m) => m.id === "JIN702C", { nom: "Updated" }); - assertEquals(db.findOne("modules", (m) => m.id === "JIN702C")?.nom, "Updated"); + db.updateWhere("modules", (m) => m.id === "JIN702C", { + nom: "Updated", + }); + assertEquals( + db.findOne("modules", (m) => m.id === "JIN702C")?.nom, + "Updated", + ); }); Deno.test("mock DB: delete module", () => {