chore: formated tests
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m9s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 1m13s
Check Deno code / Check Deno code (pull_request) Successful in 5s
Tests / Unit tests (pull_request) Successful in 12s
Tests / Integration tests (pull_request) Successful in 1m9s
Check Deno code / Check Deno code (push) Successful in 6s
Tests / Unit tests (push) Successful in 12s
Tests / Integration tests (push) Successful in 1m13s
This commit was merged in pull request #145.
This commit is contained in:
@@ -32,7 +32,10 @@ Deno.test({
|
||||
{ idModule: "M1", idUE: ue.id, idPromo: "P1", coeff: 2.0 },
|
||||
{ idModule: "M2", idUE: ue.id, idPromo: "P1", coeff: 3.0 },
|
||||
]);
|
||||
const res = await ueModulesHandler.GET!(makeGetRequest("/ue-modules"), makeEmployeeContext());
|
||||
const res = await ueModulesHandler.GET!(
|
||||
makeGetRequest("/ue-modules"),
|
||||
makeEmployeeContext(),
|
||||
);
|
||||
assertEquals(res.status, 200);
|
||||
const body = await res.json();
|
||||
assertEquals(body.length, 2);
|
||||
@@ -75,7 +78,12 @@ Deno.test({
|
||||
await seedModules([{ id: "M1", nom: "Mod A" }]);
|
||||
const [ue] = await seedUes([{ nom: "UE Info" }]);
|
||||
const res = await ueModulesHandler.POST!(
|
||||
makeJsonRequest("/ue-modules", "POST", { idModule: "M1", idUE: ue.id, idPromo: "P1", coeff: 4.0 }),
|
||||
makeJsonRequest("/ue-modules", "POST", {
|
||||
idModule: "M1",
|
||||
idUE: ue.id,
|
||||
idPromo: "P1",
|
||||
coeff: 4.0,
|
||||
}),
|
||||
makeEmployeeContext(),
|
||||
);
|
||||
assertEquals(res.status, 201);
|
||||
@@ -104,7 +112,8 @@ Deno.test({
|
||||
// --- GET /ue-modules/:idModule/:idUE/:idPromo ---
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo returns correct association (employee)",
|
||||
name:
|
||||
"e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo returns correct association (employee)",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
await seedPromotions([{ id: "P1" }, { id: "P2" }]);
|
||||
@@ -119,7 +128,11 @@ Deno.test({
|
||||
]);
|
||||
const res = await ueModuleHandler.GET!(
|
||||
makeGetRequest(`/ue-modules/M1/${ue1.id}/P1`),
|
||||
makeEmployeeContext({ idModule: "M1", idUE: String(ue1.id), idPromo: "P1" }),
|
||||
makeEmployeeContext({
|
||||
idModule: "M1",
|
||||
idUE: String(ue1.id),
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 200);
|
||||
const body = await res.json();
|
||||
@@ -132,12 +145,17 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
name:
|
||||
"e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.GET!(
|
||||
makeGetRequest("/ue-modules/M1/1/P1"),
|
||||
makeContextWithAffiliation("student", { idModule: "M1", idUE: "1", idPromo: "P1" }),
|
||||
makeContextWithAffiliation("student", {
|
||||
idModule: "M1",
|
||||
idUE: "1",
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 403);
|
||||
},
|
||||
@@ -146,7 +164,8 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
name:
|
||||
"e2e ue_modules: GET /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.GET!(
|
||||
@@ -162,7 +181,8 @@ Deno.test({
|
||||
// --- PUT /ue-modules/:idModule/:idUE/:idPromo ---
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo updates only the targeted row (employee)",
|
||||
name:
|
||||
"e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo updates only the targeted row (employee)",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
await seedPromotions([{ id: "P1" }, { id: "P2" }]);
|
||||
@@ -175,7 +195,11 @@ Deno.test({
|
||||
]);
|
||||
const res = await ueModuleHandler.PUT!(
|
||||
makeJsonRequest(`/ue-modules/M1/${ue1.id}/P1`, "PUT", { coeff: 5.0 }),
|
||||
makeEmployeeContext({ idModule: "M1", idUE: String(ue1.id), idPromo: "P1" }),
|
||||
makeEmployeeContext({
|
||||
idModule: "M1",
|
||||
idUE: String(ue1.id),
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 200);
|
||||
const body = await res.json();
|
||||
@@ -187,12 +211,17 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
name:
|
||||
"e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.PUT!(
|
||||
makeJsonRequest("/ue-modules/M1/1/P1", "PUT", { coeff: 5.0 }),
|
||||
makeContextWithAffiliation("student", { idModule: "M1", idUE: "1", idPromo: "P1" }),
|
||||
makeContextWithAffiliation("student", {
|
||||
idModule: "M1",
|
||||
idUE: "1",
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 403);
|
||||
},
|
||||
@@ -201,7 +230,8 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
name:
|
||||
"e2e ue_modules: PUT /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.PUT!(
|
||||
@@ -217,7 +247,8 @@ Deno.test({
|
||||
// --- DELETE /ue-modules/:idModule/:idUE/:idPromo ---
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo deletes only targeted row (employee)",
|
||||
name:
|
||||
"e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo deletes only targeted row (employee)",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
await seedPromotions([{ id: "P1" }, { id: "P2" }]);
|
||||
@@ -230,7 +261,11 @@ Deno.test({
|
||||
]);
|
||||
const res = await ueModuleHandler.DELETE!(
|
||||
makeGetRequest(`/ue-modules/M1/${ue1.id}/P1`),
|
||||
makeEmployeeContext({ idModule: "M1", idUE: String(ue1.id), idPromo: "P1" }),
|
||||
makeEmployeeContext({
|
||||
idModule: "M1",
|
||||
idUE: String(ue1.id),
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 204);
|
||||
// L'autre ligne doit toujours exister
|
||||
@@ -243,12 +278,17 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
name:
|
||||
"e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo 403 for non-employee",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.DELETE!(
|
||||
makeGetRequest("/ue-modules/M1/1/P1"),
|
||||
makeContextWithAffiliation("student", { idModule: "M1", idUE: "1", idPromo: "P1" }),
|
||||
makeContextWithAffiliation("student", {
|
||||
idModule: "M1",
|
||||
idUE: "1",
|
||||
idPromo: "P1",
|
||||
}),
|
||||
);
|
||||
assertEquals(res.status, 403);
|
||||
},
|
||||
@@ -257,7 +297,8 @@ Deno.test({
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
name:
|
||||
"e2e ue_modules: DELETE /ue-modules/:idModule/:idUE/:idPromo 404 when not found",
|
||||
async fn() {
|
||||
await truncateAll();
|
||||
const res = await ueModuleHandler.DELETE!(
|
||||
|
||||
Reference in New Issue
Block a user