mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-06 00:36:10 +00:00
fix: add tests for .all() routes
This commit is contained in:
@@ -219,4 +219,31 @@ describe('Swagger', () => {
|
||||
expect(response.paths['/public']).not.toBeUndefined();
|
||||
expect(response.paths['/hidden']).toBeUndefined();
|
||||
})
|
||||
|
||||
it('should expand .all routes', async () => {
|
||||
const app = new Elysia().use(swagger())
|
||||
.all("/all", "woah")
|
||||
|
||||
await app.modules
|
||||
|
||||
const res = await app.handle(req('/swagger/json'))
|
||||
expect(res.status).toBe(200)
|
||||
const response = await res.json()
|
||||
expect(Object.keys(response.paths['/all'])).toBeArrayOfSize(8)
|
||||
})
|
||||
|
||||
it('should hide routes that are invalid', async () => {
|
||||
const app = new Elysia().use(swagger())
|
||||
.get("/valid", "ok")
|
||||
.route("LOCK", "/invalid", "nope")
|
||||
|
||||
await app.modules
|
||||
|
||||
const res = await app.handle(req('/swagger/json'))
|
||||
expect(res.status).toBe(200)
|
||||
const response = await res.json()
|
||||
expect(response.paths['/valid']).not.toBeUndefined();
|
||||
expect(response.paths['/invalid']).toBeUndefined();
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
@@ -77,6 +77,7 @@ it('returns a valid Swagger/OpenAPI json config for many routes', async () => {
|
||||
)
|
||||
}
|
||||
)
|
||||
.route('LOCK', '/lock', () => 'locked')
|
||||
|
||||
await app.modules
|
||||
|
||||
|
||||
Reference in New Issue
Block a user