style: fix deno fmt and lint
This commit is contained in:
@@ -18,7 +18,10 @@ Deno.test({
|
|||||||
async fn() {
|
async fn() {
|
||||||
await truncateAll();
|
await truncateAll();
|
||||||
await seedRoles([{ nom: "admin" }, { nom: "employee" }]);
|
await seedRoles([{ nom: "admin" }, { nom: "employee" }]);
|
||||||
const res = await rolesHandler.GET!(makeGetRequest("/roles"), makeEmployeeContext());
|
const res = await rolesHandler.GET!(
|
||||||
|
makeGetRequest("/roles"),
|
||||||
|
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);
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ Deno.test({
|
|||||||
name: "integration roles: create and retrieve by id",
|
name: "integration roles: create and retrieve by id",
|
||||||
async fn() {
|
async fn() {
|
||||||
await truncateAll();
|
await truncateAll();
|
||||||
const [created] = await testDb.insert(roles).values({ nom: "viewer" }).returning();
|
const [created] = await testDb.insert(roles).values({ nom: "viewer" })
|
||||||
|
.returning();
|
||||||
assertExists(created.id);
|
assertExists(created.id);
|
||||||
assertEquals(created.nom, "viewer");
|
assertEquals(created.nom, "viewer");
|
||||||
const row = await testDb
|
const row = await testDb
|
||||||
@@ -87,7 +88,9 @@ Deno.test({
|
|||||||
{ idRole: role.id, idPermission: "note_read" },
|
{ idRole: role.id, idPermission: "note_read" },
|
||||||
]);
|
]);
|
||||||
// reset
|
// reset
|
||||||
await testDb.delete(rolePermissions).where(eq(rolePermissions.idRole, role.id));
|
await testDb.delete(rolePermissions).where(
|
||||||
|
eq(rolePermissions.idRole, role.id),
|
||||||
|
);
|
||||||
await testDb.insert(rolePermissions).values([
|
await testDb.insert(rolePermissions).values([
|
||||||
{ idRole: role.id, idPermission: "note_write" },
|
{ idRole: role.id, idPermission: "note_write" },
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ Deno.test("mock API: GET /roles/:id returns role", async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("mock API: GET /roles/:id 404 when not found", async () => {
|
Deno.test("mock API: GET /roles/:id 404 when not found", async () => {
|
||||||
mockFetch({ "/roles/99": { status: 404, body: { error: "Ressource introuvable" } } });
|
mockFetch({
|
||||||
|
"/roles/99": { status: 404, body: { error: "Ressource introuvable" } },
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const res = await fetch("http://localhost/api/roles/99");
|
const res = await fetch("http://localhost/api/roles/99");
|
||||||
assertEquals(res.status, 404);
|
assertEquals(res.status, 404);
|
||||||
@@ -120,7 +122,9 @@ Deno.test("mock API: PUT /roles/:id updates role and permissions", async () => {
|
|||||||
Deno.test("mock API: DELETE /roles/:id returns 204", async () => {
|
Deno.test("mock API: DELETE /roles/:id returns 204", async () => {
|
||||||
mockFetch({ "/roles/2": { method: "DELETE", status: 204 } });
|
mockFetch({ "/roles/2": { method: "DELETE", status: 204 } });
|
||||||
try {
|
try {
|
||||||
const res = await fetch("http://localhost/api/roles/2", { method: "DELETE" });
|
const res = await fetch("http://localhost/api/roles/2", {
|
||||||
|
method: "DELETE",
|
||||||
|
});
|
||||||
assertEquals(res.status, 204);
|
assertEquals(res.status, 204);
|
||||||
} finally {
|
} finally {
|
||||||
restoreFetch();
|
restoreFetch();
|
||||||
|
|||||||
Reference in New Issue
Block a user