index.test.ts
This file
Path
src/helper/adapter/index.test.ts
55 lines 路 1.3 KiB 路 TypeScript
Last changed by
chore: let oxfmt sort imports instead of eslint (#5442)Yusuke Wadabefore adoption859e2c2
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import { env, getRuntimeKey } from '.'import { Hono } from '../../hono'
describe('getRuntimeKey', () => { it('Should return the current runtime key', () => { // Now, using the `bun run test` command. // But `vitest` depending Node.js will run this test so the RuntimeKey will be `node`. expect(getRuntimeKey()).toBe('node') })})
describe('env', () => { describe('Types', () => { type Env = { Bindings: { MY_VAR: string } }
it('Should not throw type errors with env has generics', () => { const app = new Hono() app.get('/var', (c) => { const { MY_VAR } = env<{ MY_VAR: string }>(c) expectTypeOf<string>(MY_VAR) return c.json({ var: MY_VAR, }) }) })
it('Should not throw type errors with Hono has generics', () => { const app = new Hono<Env>()
app.get('/var', (c) => { const { MY_VAR } = env(c) expectTypeOf<string>(MY_VAR) return c.json({ var: MY_VAR, }) }) })
it('Should not throw type errors with env and Hono have generics', () => { const app = new Hono<Env>()
app.get('/var', (c) => { const { MY_VAR } = env<{ MY_VAR: string }>(c) expectTypeOf<string>(MY_VAR) return c.json({ var: MY_VAR, }) }) }) })})