Skip to content
Myr

test: add tests for builtin middleware (#192)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yusuke Wada · committed by GitHub · parent fc6a969 · Browse files · 1 file+20 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+20 added−0 removed

  • tests:+20 added−0 removed

1 file+20 added−0 removed

modified:src/hono.test.ts+20 added
1import { poweredBy } from './middleware/powered-by'2import type { Context } from '@/context'3import { Hono } from '@/hono'45describe('GET Request', () => {
277 unmodified lines
283 expect(res.headers.get('x-after')).toBe('abc')284 })285})286287describe('Builtin Middleware', () => {288 const app = new Hono()289 app.use('/abc', poweredBy())290 app.use('/def', async (c, next) => {291 const middleware = poweredBy()292 await middleware(c, next)293 })294295 it('"powered-by" middleware', async () => {296 const res = await app.request('http://localhost/abc')297 expect(res.headers.get('x-powered-by')).toBe('Hono')298 })299300 it('"powered-by" middleware in a handler', async () => {301 const res = await app.request('http://localhost/def')302 expect(res.headers.get('x-powered-by')).toBe('Hono')303 })304})305306describe('Not Found', () => {307 const app = new Hono()308309 app.notFound((c) => {
104 unmodified lines