Skip to content

Commit

Permalink
Test several path parameters with an integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Santeri Hiltunen committed Nov 5, 2018
1 parent 09032d7 commit 2a8d73e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/integration/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ app.get(
}
);

app.get(
"/parameters/several/:a/a/:b/b/:c",
validator.validate("get", "/parameters/several/{a}/a/{b}/b/{c}"),
(req, res, _next) => {
res.json(req.params);
}
);

app.get(
"/parameters/header",
validator.validate("get", "/parameters/header"),
Expand Down
6 changes: 6 additions & 0 deletions test/integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ describe("Integration tests with real app", () => {
expect(res.body).toEqual({ param: "hallo", porom: "moi" });
});

test("several path parameters are validated", async () => {
const res = await request(app).get("/parameters/several/aa/a/bb/b/cc");
expect(res.status).toBe(200);
expect(res.body).toEqual({ a: "aa", b: "bb", c: "cc" });
});

test("header parameters are validated", async () => {
let res = await request(app).get("/parameters/header");
expect(res.status).toBe(400);
Expand Down

0 comments on commit 2a8d73e

Please sign in to comment.