0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 10:51:01 +00:00
hono/test/middleware.test.ts

21 lines
572 B
TypeScript
Raw Normal View History

import makeServiceWorkerEnv from 'service-worker-mock'
import { Hono, Middleware } from '../src/hono'
2022-01-01 07:22:35 +00:00
declare var global: any
Object.assign(global, makeServiceWorkerEnv())
2022-01-01 07:22:35 +00:00
describe('Builtin Middleware', () => {
const app = new Hono()
app.use('*', Middleware.poweredBy())
app.get('/', () => new Response('root'))
2022-01-01 07:22:35 +00:00
it('Builtin Powered By Middleware', async () => {
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')
})
})