Skip to content

Commit 352e286

Browse files
committed
test(backend): add validation tests for waitlist controller to handle missing schema version
1 parent c62dc27 commit 352e286

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/backend/src/waitlist/controller/waitlist.controller-add.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ describe("POST /api/waitlist", () => {
4747

4848
expect(res.status).toBe(400);
4949
expect(res.error).toBeDefined();
50+
expect(mockAddToWaitlist).not.toHaveBeenCalled();
51+
});
52+
53+
it("should return 400 if schema version is missing", async () => {
54+
app = await createTestApp({
55+
service: {
56+
__esModule: true,
57+
default: { addToWaitlist: mockAddToWaitlist },
58+
},
59+
});
60+
61+
const res = await request(app)
62+
.post("/api/waitlist")
63+
.send({ email: "test@example.com" });
64+
65+
expect(res.status).toBe(400);
66+
expect(res.error).toBeDefined();
67+
expect(mockAddToWaitlist).not.toHaveBeenCalled();
5068
});
5169

5270
it("should return 200 if v1 answers are valid", async () => {

packages/backend/src/waitlist/controller/waitlist.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class WaitlistController {
4343
if (!parseResult.success) {
4444
return res
4545
.status(400)
46-
.json({ error: "Invalid input", details: parseResult.error.flatten() });
46+
.json({ error: "Invalid answer", details: parseResult.error });
4747
}
4848

4949
try {

0 commit comments

Comments
 (0)