style: fix deno fmt and lint
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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<Module>("modules", (m) => m.id === "JIN702C", { nom: "Updated" });
|
||||
assertEquals(db.findOne<Module>("modules", (m) => m.id === "JIN702C")?.nom, "Updated");
|
||||
db.updateWhere<Module>("modules", (m) => m.id === "JIN702C", {
|
||||
nom: "Updated",
|
||||
});
|
||||
assertEquals(
|
||||
db.findOne<Module>("modules", (m) => m.id === "JIN702C")?.nom,
|
||||
"Updated",
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("mock DB: delete module", () => {
|
||||
|
||||
Reference in New Issue
Block a user