Skip to content

Commit 97158fd

Browse files
author
carmine
committed
fix test
1 parent ecba075 commit 97158fd

File tree

1 file changed

+52
-19
lines changed

1 file changed

+52
-19
lines changed

test/1022.spec.ts

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as request from 'supertest';
33
import { createApp } from './common/app';
44
import * as packageJson from '../package.json';
55
import { OpenAPIV3 } from '../src/framework/types';
6-
import {expect} from "chai";
6+
import { expect } from 'chai';
77

88
describe(packageJson.name, () => {
99
let app = null;
@@ -63,12 +63,12 @@ describe(packageJson.name, () => {
6363
required: ['id'],
6464
properties: {
6565
id: {
66-
type: 'integer'
67-
}
68-
}
69-
}
70-
}
71-
}
66+
type: 'integer',
67+
},
68+
},
69+
},
70+
},
71+
},
7272
},
7373
responses: {
7474
'200': {
@@ -88,6 +88,26 @@ describe(packageJson.name, () => {
8888
},
8989
},
9090
},
91+
92+
'/some/{wildcard}*': {
93+
parameters: [
94+
{
95+
name: 'wildcard',
96+
in: 'path',
97+
required: true,
98+
schema: {
99+
type: 'string',
100+
},
101+
},
102+
],
103+
get: {
104+
responses: {
105+
'200': {
106+
description: 'OK',
107+
},
108+
},
109+
},
110+
},
91111
},
92112
};
93113

@@ -102,8 +122,17 @@ describe(packageJson.name, () => {
102122
app.use(
103123
express
104124
.Router()
105-
.get(`/api/test/:id`, (req, res) => res.status(200).json({ id: 'id-test', label: 'label'}))
106-
.post(`/api/test/:id:clone`, (req, res) => res.status(200).json({...req.body, id: 'id-test'})),
125+
.get(`/api/test/:id`, (req, res) =>
126+
res.status(200).json({ id: 'id-test', label: 'label' }),
127+
)
128+
.post(`/api/test/:id:clone`, (req, res) =>
129+
res.status(200).json({ ...req.body, id: 'id-test' }),
130+
)
131+
.get('/api/some/:wildcard(*)', (req, res) => {
132+
const wildcard = req.params.wildcard;
133+
console.log(`Wildcard: ${wildcard}`);
134+
res.status(200).send(`Matched wildcard: ${wildcard}`);
135+
}),
107136
),
108137
);
109138
});
@@ -112,19 +141,23 @@ describe(packageJson.name, () => {
112141
app.server.close();
113142
});
114143

115-
it('get /test/{id} should return 200', async () =>
144+
it('GET /test/{id} should return 200', async () =>
116145
request(app).get(`/api/test/abc123`).expect(200));
117146

118147
it('POST /test/{id}:clone should return 200', async () =>
119-
request(app).post(`/api/test/abc123:clone`)
120-
.send({ id: 10 })
121-
.expect(200));
148+
request(app).post(`/api/test/abc123:clone`).send({ id: 10 }).expect(200));
122149

123150
it('POST /test/{id}:clone should return 400', async () =>
124-
request(app).post(`/api/test/abc123:clone`)
125-
.send({ id: 'abc123' })
126-
.expect(400)
127-
.then(r => {
128-
expect(r.body.message).to.include('id must be integer');
129-
}));
151+
request(app)
152+
.post(`/api/test/abc123:clone`)
153+
.send({ id: 'abc123' })
154+
.expect(400)
155+
.then((r) => {
156+
expect(r.body.message).to.include('id must be integer');
157+
}));
158+
159+
it('GET /some/test with wildcard should return 200', async () =>
160+
request(app)
161+
.get(`/api/some/test/stuff`)
162+
.expect(200));
130163
});

0 commit comments

Comments
 (0)