Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/core/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ describe('Testing App routing', () => {

await makeFetch(app.listen())('/abc').expect(200, 'Hello World')
})
it('should ignore a non-string, non-array base path and mount at root', async () => {
const app = new App()

app.use(123 as unknown as string, (_req, res) => void res.send('Hello world'))

await makeFetch(app.listen())('/').expect(200, 'Hello world')
})
it('should can set url prefix for the application', async () => {
const app = new App()

Expand Down
7 changes: 7 additions & 0 deletions tests/core/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -794,4 +794,11 @@ describe('Request properties', () => {

await fetch('/', { headers: { 'If-None-Match': etag, 'Cache-Control': 'max-age=3600' } }).expectStatus(304)
})
it('req.stale is true when the response is not fresh', async () => {
const { fetch } = InitAppAndTest((req, res) => {
res.send(`stale: ${req.stale}`)
})

await fetch('/').expect(200, 'stale: true')
})
})
10 changes: 10 additions & 0 deletions tests/modules/negotiator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@ describe('Negotiator', () => {
const negotiator = new Negotiator(createRequest({ accept: 'text/html;level' }))
expect(negotiator.mediaTypes()).toEqual(['text/html'])
})

it('should match when accept parameter has an empty value', () => {
const negotiator = new Negotiator(createRequest({ accept: 'text/html;level=' }))
expect(negotiator.mediaTypes(['text/html;level='])).toEqual(['text/html;level='])
})

it('should not match when accept parameter has an empty value but provided does not', () => {
const negotiator = new Negotiator(createRequest({ accept: 'text/html;level=' }))
expect(negotiator.mediaTypes(['text/html;level=1'])).toEqual([])
})
})

describe('edge cases', () => {
Expand Down