2022-01-03 22:02:31 +00:00
|
|
|
const { makeEdgeEnv } = require('edge-mock')
|
2022-01-03 22:43:46 +00:00
|
|
|
const { Hono, Middleware } = require('../src/hono')
|
2022-01-01 07:22:35 +00:00
|
|
|
|
2022-01-03 22:02:31 +00:00
|
|
|
makeEdgeEnv()
|
|
|
|
|
2022-01-01 07:22:35 +00:00
|
|
|
describe('Builtin Middleware', () => {
|
|
|
|
const app = new Hono()
|
|
|
|
|
|
|
|
app.use('*', Middleware.poweredBy)
|
2022-01-03 22:02:31 +00:00
|
|
|
app.get('/', () => new Response('root'))
|
2022-01-01 07:22:35 +00:00
|
|
|
|
|
|
|
it('Builtin Powered By Middleware', async () => {
|
2022-01-03 22:02:31 +00:00
|
|
|
let req = new Request('/')
|
|
|
|
let res = await app.dispatch(req)
|
2022-01-01 07:22:35 +00:00
|
|
|
expect(res).not.toBeNull()
|
|
|
|
expect(res.status).toBe(200)
|
|
|
|
expect(res.headers.get('X-Powered-By')).toBe('Hono')
|
|
|
|
})
|
|
|
|
})
|