style: fix deno fmt and lint
Check Deno code / Check Deno code (pull_request) Successful in 6s
Tests / Unit tests (pull_request) Successful in 11s
Tests / Integration tests (pull_request) Successful in 58s

This commit is contained in:
2026-04-26 14:18:55 +02:00
committed by djalim
parent a791b8813d
commit 3ac514a33d
3 changed files with 62 additions and 11 deletions
+34 -6
View File
@@ -6,7 +6,11 @@ import {
makeGetRequest,
makeJsonRequest,
} from "../helpers/handler.ts";
import { seedRoles, seedUsers, truncateAll } from "../helpers/db_integration.ts";
import {
seedRoles,
seedUsers,
truncateAll,
} from "../helpers/db_integration.ts";
import { handler as usersHandler } from "$apps/admin/api/users.ts";
import { handler as userHandler } from "$apps/admin/api/users/[id].ts";
@@ -87,7 +91,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "dup.user", nom: "A", prenom: "A", idRole: role.id }]);
await seedUsers([{
id: "dup.user",
nom: "A",
prenom: "A",
idRole: role.id,
}]);
const res = await usersHandler.POST!(
makeJsonRequest("/users", "POST", {
id: "dup.user",
@@ -124,7 +133,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "test.user", nom: "Test", prenom: "User", idRole: role.id }]);
await seedUsers([{
id: "test.user",
nom: "Test",
prenom: "User",
idRole: role.id,
}]);
const res = await userHandler.GET!(
makeGetRequest("/users/test.user"),
makeEmployeeContext({ id: "test.user" }),
@@ -158,7 +172,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "upd.user", nom: "Old", prenom: "Name", idRole: role.id }]);
await seedUsers([{
id: "upd.user",
nom: "Old",
prenom: "Name",
idRole: role.id,
}]);
const res = await userHandler.PUT!(
makeJsonRequest("/users/upd.user", "PUT", {
nom: "New",
@@ -180,7 +199,11 @@ Deno.test({
async fn() {
await truncateAll();
const res = await userHandler.PUT!(
makeJsonRequest("/users/ghost", "PUT", { nom: "X", prenom: "Y", idRole: 1 }),
makeJsonRequest("/users/ghost", "PUT", {
nom: "X",
prenom: "Y",
idRole: 1,
}),
makeEmployeeContext({ id: "ghost" }),
);
assertEquals(res.status, 404);
@@ -196,7 +219,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "del.user", nom: "Del", prenom: "Me", idRole: role.id }]);
await seedUsers([{
id: "del.user",
nom: "Del",
prenom: "Me",
idRole: role.id,
}]);
const res = await userHandler.DELETE!(
makeGetRequest("/users/del.user"),
makeEmployeeContext({ id: "del.user" }),
+18 -3
View File
@@ -55,7 +55,12 @@ Deno.test({
const [role] = await seedRoles([{ nom: "admin" }]);
const [created] = await testDb
.insert(users)
.values({ id: "durand.claire", nom: "Durand", prenom: "Claire", idRole: role.id })
.values({
id: "durand.claire",
nom: "Durand",
prenom: "Claire",
idRole: role.id,
})
.returning();
assertExists(created);
assertEquals(created.id, "durand.claire");
@@ -91,7 +96,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "test.user", nom: "Test", prenom: "User", idRole: role.id }]);
await seedUsers([{
id: "test.user",
nom: "Test",
prenom: "User",
idRole: role.id,
}]);
const [updated] = await testDb
.update(users)
.set({ nom: "Updated", prenom: "Name" })
@@ -109,7 +119,12 @@ Deno.test({
async fn() {
await truncateAll();
const [role] = await seedRoles([{ nom: "employee" }]);
await seedUsers([{ id: "to.delete", nom: "Del", prenom: "Me", idRole: role.id }]);
await seedUsers([{
id: "to.delete",
nom: "Del",
prenom: "Me",
idRole: role.id,
}]);
await testDb.delete(users).where(eq(users.id, "to.delete"));
const row = await testDb
.select()
+10 -2
View File
@@ -40,7 +40,12 @@ Deno.test("GET /users - filters by idRole", async () => {
// --- POST /users ---
Deno.test("POST /users - creates a user and returns 201", async () => {
const newUser = { id: "durand.claire", nom: "Durand", prenom: "Claire", idRole: 1 };
const newUser = {
id: "durand.claire",
nom: "Durand",
prenom: "Claire",
idRole: 1,
};
mockFetch({ [BASE]: { method: "POST", status: 201, body: newUser } });
try {
const res = await fetch(BASE, {
@@ -110,7 +115,10 @@ Deno.test("GET /users/{id} - returns a user by id", async () => {
Deno.test("GET /users/{id} - returns 404 for unknown id", async () => {
mockFetch({
[`${BASE}/inconnu`]: { status: 404, body: { error: "Ressource introuvable" } },
[`${BASE}/inconnu`]: {
status: 404,
body: { error: "Ressource introuvable" },
},
});
try {
const res = await fetch(`${BASE}/inconnu`);