Skip to content

Commit

Permalink
Add multiple path parameters with wildcard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell3514 committed Jan 31, 2024
1 parent bdd0d79 commit 327646e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/resources/wildcard.path.params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,42 @@ paths:

/d3:
get:
responses:
200:
description: dummy response
content: {}

/d4/{multi}/spaced/{path}(*):
get:
parameters:
- name: multi
in: path
required: true
schema:
type: string
- name: path
in: path
required: true
schema:
type: string
responses:
200:
description: dummy response
content: {}

/d5/{multi}/{path}(*):
get:
parameters:
- name: multi
in: path
required: true
schema:
type: string
- name: path
in: path
required: true
schema:
type: string
responses:
200:
description: dummy response
Expand Down
28 changes: 28 additions & 0 deletions test/wildcard.path.params.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ describe('wildcard path params', () => {
res.json({
success: true,
}),
)
.get(`${app.basePath}/d4/:multi/spaced/:path(*)`, (req, res) =>
res.json({
...req.params,
}),
)
.get(`${app.basePath}/d5/:multi/:path(*)`, (req, res) =>
res.json({
...req.params,
}),
);
},
);
Expand Down Expand Up @@ -83,4 +93,22 @@ describe('wildcard path params', () => {
.then((r) => {
expect(r.body.success).to.be.true;
}));

it('should return 200 when wildcard path includes all required params and multiple path params', async () =>
request(app)
.get(`${app.basePath}/d4/one/spaced/two/three/four`)
.expect(200)
.then((r) => {
expect(r.body.multi).to.equal('one');
expect(r.body.path).to.equal('two/three/four');
}));

it('should return 200 when wildcard path includes all required params and multiple path params', async () =>
request(app)
.get(`${app.basePath}/d5/one/two/three/four`)
.expect(200)
.then((r) => {
expect(r.body.multi).to.equal('one');
expect(r.body.path).to.equal('two/three/four');
}));
});

0 comments on commit 327646e

Please sign in to comment.