Skip to content

Commit 0c55318

Browse files
committed
Add multiple path parameters with wildcard tests
1 parent 4b0c989 commit 0c55318

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

test/resources/wildcard.path.params.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,42 @@ paths:
5252

5353
/d3:
5454
get:
55+
responses:
56+
200:
57+
description: dummy response
58+
content: {}
59+
60+
/d4/{multi}/spaced/{path}(*):
61+
get:
62+
parameters:
63+
- name: multi
64+
in: path
65+
required: true
66+
schema:
67+
type: string
68+
- name: path
69+
in: path
70+
required: true
71+
schema:
72+
type: string
73+
responses:
74+
200:
75+
description: dummy response
76+
content: {}
77+
78+
/d5/{multi}/{path}(*):
79+
get:
80+
parameters:
81+
- name: multi
82+
in: path
83+
required: true
84+
schema:
85+
type: string
86+
- name: path
87+
in: path
88+
required: true
89+
schema:
90+
type: string
5591
responses:
5692
200:
5793
description: dummy response

test/wildcard.path.params.spec.ts

+28
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ describe('wildcard path params', () => {
3434
res.json({
3535
success: true,
3636
}),
37+
)
38+
.get(`${app.basePath}/d4/:multi/spaced/:path(*)`, (req, res) =>
39+
res.json({
40+
...req.params,
41+
}),
42+
)
43+
.get(`${app.basePath}/d5/:multi/:path(*)`, (req, res) =>
44+
res.json({
45+
...req.params,
46+
}),
3747
);
3848
},
3949
);
@@ -83,4 +93,22 @@ describe('wildcard path params', () => {
8393
.then((r) => {
8494
expect(r.body.success).to.be.true;
8595
}));
96+
97+
it('should return 200 when wildcard path includes all required params and multiple path params', async () =>
98+
request(app)
99+
.get(`${app.basePath}/d4/one/spaced/two/three/four`)
100+
.expect(200)
101+
.then((r) => {
102+
expect(r.body.multi).to.equal('one');
103+
expect(r.body.path).to.equal('two/three/four');
104+
}));
105+
106+
it('should return 200 when wildcard path includes all required params and multiple path params', async () =>
107+
request(app)
108+
.get(`${app.basePath}/d5/one/two/three/four`)
109+
.expect(200)
110+
.then((r) => {
111+
expect(r.body.multi).to.equal('one');
112+
expect(r.body.path).to.equal('two/three/four');
113+
}));
86114
});

0 commit comments

Comments
 (0)