Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests benefits #7

Merged
merged 2 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
Loading