diff --git a/server/__tests__/calculation.test.js b/server/__tests__/calculation.test.js index d3871ccd..dbf62f56 100644 --- a/server/__tests__/calculation.test.js +++ b/server/__tests__/calculation.test.js @@ -92,6 +92,20 @@ describe("Calculation API Endpoints", () => { newCalcId = res.body.id; }); + // POST "/" Create a calculation with invalid body (Admin only) + it("should create a calculation", async () => { + const res = await request(server) + .post("/api/calculations") + .set("Authorization", `Bearer ${adminToken}`) + .send({ + name: true, + description: 1, + deprecated: true, + id: "string" + }); + expect(res.statusCode).toEqual(400); + }); + // PUT "/:id" Update calculation (Admin only) it("should update a calculation", async () => { const res = await request(server) @@ -106,6 +120,20 @@ describe("Calculation API Endpoints", () => { expect(res.statusCode).toEqual(200); }); + // PUT "/:id" Update calculation with invalid body(Admin only) + it("should update a calculation", async () => { + const res = await request(server) + .put(`/api/calculations/${newCalcId}`) + .set("Authorization", `Bearer ${adminToken}`) + .send({ + name: true, + description: 1, + deprecated: true, + id: "string" + }); + expect(res.statusCode).toEqual(400); + }); + // PUT "/:id" Update calculation using inexistent id (Admin only) //TODO: this endpoint logic needs error handling for inexistent ids