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

18 lines
533 B
JavaScript
Raw Normal View History

2022-01-01 07:22:35 +00:00
const fetch = require('node-fetch')
const { Hono, Middleware } = require('./hono')
describe('Builtin Middleware', () => {
const app = new Hono()
app.use('*', Middleware.poweredBy)
app.get('/', () => new fetch.Response('root'))
it('Builtin Powered By Middleware', async () => {
let req = new fetch.Request('https://example.com/')
let res = await app.dispatch(req, new fetch.Response())
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(res.headers.get('X-Powered-By')).toBe('Hono')
})
})