Skip to content

Commit

Permalink
test(express-5): change routes in tests to matchers in express 5
Browse files Browse the repository at this point in the history
  • Loading branch information
SF97 committed Dec 30, 2024
1 parent 1d69d8a commit 9a2857c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/1022.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ describe(packageJson.name, () => {
.get(`/api/test/:id`, (req, res) =>
res.status(200).json({ id: 'id-test', label: 'label' }),
)
.post(`/api/test/:id:clone`, (req, res) =>
.post(`/api/test/:id\\:clone`, (req, res) =>
res.status(200).json({ ...req.body, id: 'id-test' }),
)
.get('/api/some/:wildcard(*)', (req, res) => {
.get('/api/some/:wildcard(*wildcard)', (req, res) => {
const wildcard = req.params.wildcard;
console.log(`Wildcard: ${wildcard}`);
res.status(200).send(`Matched wildcard: ${wildcard}`);
Expand Down
4 changes: 2 additions & 2 deletions test/699.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('699', () => {
},
3005,
(app) => {
app.get([`${app.basePath}/users/:id?`], (req, res) => {
app.get([`${app.basePath}/users/{:id}`], (req, res) => {
if (typeof req.params.id !== 'object') {
throw new Error("Should be deserialized to ObjectId object");
}
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('699 serialize response components only', () => {
},
3005,
(app) => {
app.get([`${app.basePath}/users/:id?`], (req, res) => {
app.get([`${app.basePath}/users/{:id}`], (req, res) => {
if (typeof req.params.id !== 'string') {
throw new Error("Should be not be deserialized to ObjectId object");
}
Expand Down
2 changes: 1 addition & 1 deletion test/multipart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('a multipart request', () => {
metadata: req.body.metadata,
});
})
.post(`/sample_*`, (req, res) => res.json(req.body)),
.post(`/sample_*suffix`, (req, res) => res.json(req.body)),
),
);
});
Expand Down
4 changes: 2 additions & 2 deletions test/path.params.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('path params', () => {
3005,
(app) => {
app.get(
[`${app.basePath}/users/:id?`, `${app.basePath}/users_alt/:id?`],
[`${app.basePath}/users/{:id}`, `${app.basePath}/users_alt/{:id}`],
(req, res) => {
res.json({
id: req.params.id,
Expand All @@ -30,7 +30,7 @@ describe('path params', () => {
id: req.params.name,
});
});
app.get(`${app.basePath}/multi_users/:ids?`, (req, res) => {
app.get(`${app.basePath}/multi_users/{:ids}`, (req, res) => {
res.json({
ids: req.params.ids,
});
Expand Down
6 changes: 3 additions & 3 deletions test/serdes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('serdes', () => {
},
3005,
(app) => {
app.get([`${app.basePath}/users/:id?`], (req, res) => {
app.get([`${app.basePath}/users/{:id}`], (req, res) => {
if (typeof req.params.id !== 'object') {
throw new Error("Should be deserialized to ObjectId object");
}
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('serdes serialize response components only', () => {
},
3005,
(app) => {
app.get([`${app.basePath}/users/:id?`], (req, res) => {
app.get([`${app.basePath}/users/{:id}`], (req, res) => {
if (typeof req.params.id !== 'string') {
throw new Error("Should be not be deserialized to ObjectId object");
}
Expand Down Expand Up @@ -431,7 +431,7 @@ describe('serdes with array type string-list', () => {
},
3005,
(app) => {
app.get([`${app.basePath}/users/:id?`], (req, res) => {
app.get([`${app.basePath}/users/{:id}`], (req, res) => {
if (typeof req.params.id !== 'object') {
throw new Error("Should be deserialized to ObjectId object");
}
Expand Down

0 comments on commit 9a2857c

Please sign in to comment.