0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 10:51:01 +00:00
hono/test/middleware.test.ts
Yusuke Wada e6039f69f9
Migrate to TypeScript (#21)
* Migrate to TypeScript

* ready for publish
2022-01-05 18:41:29 +09:00

21 lines
572 B
TypeScript

import makeServiceWorkerEnv from 'service-worker-mock'
import { Hono, Middleware } from '../src/hono'
declare var global: any
Object.assign(global, makeServiceWorkerEnv())
describe('Builtin Middleware', () => {
const app = new Hono()
app.use('*', Middleware.poweredBy())
app.get('/', () => new Response('root'))
it('Builtin Powered By Middleware', async () => {
let req = new Request('/')
let res = await app.dispatch(req)
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(res.headers.get('X-Powered-By')).toBe('Hono')
})
})