Skip to content

Commit

Permalink
fix: add tests for .all() routes
Browse files Browse the repository at this point in the history
  • Loading branch information
itsactuallyluna9 committed Aug 3, 2024
1 parent 1a78ff0 commit d6fda56
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

})
})
1 change: 1 addition & 0 deletions test/validate-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ it('returns a valid Swagger/OpenAPI json config for many routes', async () => {
)
}
)
.route('LOCK', '/lock', () => 'locked')

await app.modules

Expand Down

0 comments on commit d6fda56

Please sign in to comment.