Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fehmer committed Aug 23, 2024
1 parent 8f682bf commit 9e83918
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions backend/__tests__/api/controllers/dev.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe("DevController", () => {
isDevEnvironmentMock.mockReset();
isDevEnvironmentMock.mockReturnValue(true);
});

it("should fail on prod", async () => {
//GIVEN
isDevEnvironmentMock.mockReturnValue(false);
Expand All @@ -28,5 +29,31 @@ describe("DevController", () => {
"Development endpoints are only available in DEV mode."
);
});
it("should fail without mandatory properties", async () => {
//WHEN
const { body } = await mockApp
.post("/dev/generateData")
.send({})
.expect(422);

//THEN
expect(body).toEqual({
message: "Invalid request data schema",
validationErrors: [`"username" Required`],
});
});
it("should fail with unknown properties", async () => {
//WHEN
const { body } = await mockApp
.post("/dev/generateData")
.send({ username: "Bob", extra: "value" })
.expect(422);

//THEN
expect(body).toEqual({
message: "Invalid request data schema",
validationErrors: ["Unrecognized key(s) in object: 'extra'"],
});
});
});
});

0 comments on commit 9e83918

Please sign in to comment.