Skip to content

Commit

Permalink
test: return error when API reports it
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Monteiro <[email protected]>
Co-authored-by: Jessica Luiza Silva de Oliveira <[email protected]>
Co-authored-by: Marcella Sanderle <[email protected]>
  • Loading branch information
4 people committed Sep 21, 2024
1 parent 7f7549e commit 95490bc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/app/__tests__/rotina.service.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ describe("getAllRotina", () => {
}
}
});

it("deve lançar um erro quando a API retorna um erro", async () => {
// Mock para simular uma resposta de erro
global.fetch = jest.fn().mockResolvedValue({
json: async () => ({
message: "Mensagem de erro",
status: 400,
}),
status: 400,
});

const filter = {};
const order = {};

await expect(getAllRotina(filter, order)).rejects.toThrow("Mensagem de erro");
});
});

describe("deleteRotina", () => {
Expand Down

0 comments on commit 95490bc

Please sign in to comment.