Skip to content

Commit

Permalink
chore(@nestjs/swagger): fixup explorer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mothershipper committed May 12, 2023
1 parent fcf1479 commit f964c39
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions test/explorer/swagger-explorer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,12 +1467,10 @@ describe('SwaggerExplorer', () => {
});
});
});

describe('when @All(...) is used', () => {

describe('when @All(...) is used', () => {
@Controller('')
class AllController {

@All('*')
all(): Promise<void> {
return Promise.resolve();
Expand All @@ -1492,10 +1490,23 @@ describe('SwaggerExplorer', () => {
);

expect(routes.length).toEqual(7);
expect(['get', 'post', 'put', 'delete', 'patch', 'options', 'head'].every((method) => routes.find((route) => route.root.method === method))).toBe(true);
expect(routes.find((route) => route.root.method === 'all')).toBe(undefined);
expect(
['get', 'post', 'put', 'delete', 'patch', 'options', 'head'].every(
(method) => routes.find((route) => route.root.method === method)
)
).toBe(true);
expect(routes.find((route) => route.root.method === 'all')).toBe(
undefined
);
// check if all routes are equal except for method
expect(routes.filter((v, i, a) => a.findIndex(v2 => ['path', 'parameter'].every(k => v2[k] === v[k])) === i).length).toEqual(1);
expect(
routes.filter(
(v, i, a) =>
a.findIndex((v2) =>
['path', 'parameter'].every((k) => v2[k] === v[k])
) === i
).length
).toEqual(1);
});
});

Expand Down Expand Up @@ -1544,6 +1555,7 @@ describe('SwaggerExplorer', () => {
instance: new FooController(),
metatype: FooController
} as InstanceWrapper<FooController>,
new ApplicationConfig(),
'path'
);

Expand Down

0 comments on commit f964c39

Please sign in to comment.