Skip to content

Commit

Permalink
Merge pull request #7 from fga-eps-mds/tests-benefits
Browse files Browse the repository at this point in the history
Tests benefits
  • Loading branch information
saracampss authored Sep 8, 2024
2 parents 3d9b7fa + 90a34cf commit 3ccfde5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/Controllers/newController.js

This file was deleted.

32 changes: 32 additions & 0 deletions src/__tests__/benefitsFormController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ describe("BenefitsForm Controller Tests", () => {
expect(res.status).toBe(201);
});

it("should not create an invalid benefit", async () => {
const invalid = {
nome: "",
razaoSocial: "",
statusConvenio: "",
considerarIr: "",
descontoAut: "",
};

const res = await request(app).post("/benefits/create").send(invalid);

expect(res.status).toBe(400);
});

it("should get benefit by id", async () => {
const { body: createdBenefit } = await request(app)
.post("/benefits/create")
Expand All @@ -72,6 +86,12 @@ describe("BenefitsForm Controller Tests", () => {
expect(res.status).toBe(200);
});

it("should not get benefit without id", async () => {
const res = await request(app).get(`/benefits/A1`);

expect(res.status).toBe(400);
});

it("should get benefits", async () => {
const benefitsModelCount = await BenefitsModel.countDocuments({});
const res = await request(app).get("/benefits");
Expand All @@ -96,6 +116,12 @@ describe("BenefitsForm Controller Tests", () => {
expect(res.status).toBe(200);
});

it("should not delete benefit without id", async () => {
const res = await request(app).delete(`/benefits/delete/A1`);

expect(res.status).toBe(400);
});

it("should update benefit", async () => {
const { body: createdBenefit } = await request(app)
.post("/benefits/create")
Expand All @@ -110,4 +136,10 @@ describe("BenefitsForm Controller Tests", () => {

expect(res.status).toBe(200);
});

it("should fail to update benefit", async () => {
const res = await request(app).patch(`/benefits/update/A1`);

expect(res.status).toBe(400);
});
});

0 comments on commit 3ccfde5

Please sign in to comment.