tiny.test.ts
This file
Path
src/preset/tiny.test.ts
42 lines 路 964 bytes 路 TypeScript
Last changed by
Not known.
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940414243import { getRouterName } from '../helper/dev'import { Hono } from './tiny'
describe('hono/tiny preset', () => { it('Should have PatternRouter', async () => { const app = new Hono() expect(getRouterName(app)).toBe('PatternRouter') })})
describe('Generics for Bindings and Variables', () => { interface CloudflareBindings { MY_VARIABLE: string }
it('Should not throw type errors', () => { // @ts-expect-error Bindings should extend object new Hono<{ Bindings: number }>()
const appWithInterface = new Hono<{ Bindings: CloudflareBindings }>()
appWithInterface.get('/', (c) => { expectTypeOf(c.env.MY_VARIABLE).toMatchTypeOf<string>() return c.text('/') })
const appWithType = new Hono<{ Bindings: { foo: string } }>()
appWithType.get('/', (c) => { expectTypeOf(c.env.foo).toMatchTypeOf<string>() return c.text('Hello Hono!') }) })})