style: fix deno fmt and lint

This commit is contained in:
2026-04-26 14:18:55 +02:00
committed by djalim
parent c86d20ca81
commit c5d02a2890
3 changed files with 42 additions and 10 deletions
+8 -2
View File
@@ -17,8 +17,14 @@ Deno.test({
name: "e2e modules: GET /modules returns all as employee", name: "e2e modules: GET /modules returns all as employee",
async fn() { async fn() {
await truncateAll(); await truncateAll();
await seedModules([{ id: "MATH101", nom: "Mathématiques" }, { id: "INFO101", nom: "Informatique" }]); await seedModules([{ id: "MATH101", nom: "Mathématiques" }, {
const res = await modulesHandler.GET!(makeGetRequest("/modules"), makeEmployeeContext()); id: "INFO101",
nom: "Informatique",
}]);
const res = await modulesHandler.GET!(
makeGetRequest("/modules"),
makeEmployeeContext(),
);
assertEquals(res.status, 200); assertEquals(res.status, 200);
const body = await res.json(); const body = await res.json();
assertEquals(body.length, 2); assertEquals(body.length, 2);
+8 -2
View File
@@ -9,7 +9,10 @@ Deno.test({
name: "integration modules: list all modules", name: "integration modules: list all modules",
async fn() { async fn() {
await truncateAll(); 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); const rows = await testDb.select().from(modules);
assertEquals(rows.length, 2); assertEquals(rows.length, 2);
}, },
@@ -21,7 +24,10 @@ Deno.test({
name: "integration modules: create and retrieve by id", name: "integration modules: create and retrieve by id",
async fn() { async fn() {
await truncateAll(); 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); assertExists(created);
assertEquals(created.id, "PHYS101"); assertEquals(created.id, "PHYS101");
+26 -6
View File
@@ -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 () => { 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 { try {
const res = await fetch("http://localhost/api/modules/UNKNOWN"); const res = await fetch("http://localhost/api/modules/UNKNOWN");
assertEquals(res.status, 404); 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 () => { 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 { try {
const res = await fetch("http://localhost/api/modules", { const res = await fetch("http://localhost/api/modules", {
method: "POST", 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 () => { Deno.test("mock API: PUT /modules/:id updates nom", async () => {
const updated: Module = { id: "JIN702C", nom: "Optimisation avancée" }; 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 { try {
const res = await fetch("http://localhost/api/modules/JIN702C", { const res = await fetch("http://localhost/api/modules/JIN702C", {
method: "PUT", 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 () => { Deno.test("mock API: DELETE /modules/:id returns 204", async () => {
mockFetch({ "/modules/JIN702C": { method: "DELETE", status: 204 } }); mockFetch({ "/modules/JIN702C": { method: "DELETE", status: 204 } });
try { 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); assertEquals(res.status, 204);
} finally { } finally {
restoreFetch(); restoreFetch();
@@ -140,8 +155,13 @@ Deno.test("mock DB: insert module", () => {
Deno.test("mock DB: update module nom", () => { Deno.test("mock DB: update module nom", () => {
const db = createMockDb({ tables: { modules: [...modules] } }); const db = createMockDb({ tables: { modules: [...modules] } });
db.updateWhere<Module>("modules", (m) => m.id === "JIN702C", { nom: "Updated" }); db.updateWhere<Module>("modules", (m) => m.id === "JIN702C", {
assertEquals(db.findOne<Module>("modules", (m) => m.id === "JIN702C")?.nom, "Updated"); nom: "Updated",
});
assertEquals(
db.findOne<Module>("modules", (m) => m.id === "JIN702C")?.nom,
"Updated",
);
}); });
Deno.test("mock DB: delete module", () => { Deno.test("mock DB: delete module", () => {