conninfo.test.ts
This file
Path
adapters/netlify/src/conninfo.test.ts
41 lines 路 927 bytes 路 TypeScript
Last changed by
feat(adapters/netlify): publish to JSR (#5468)Yusuke Wadabefore adoption72f0d8d
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142import { Context } from 'hono'import { getConnInfo } from './conninfo.ts'
describe('getConnInfo', () => { it('Should return the client IP from context.ip', () => { const ip = '203.0.113.50' const c = new Context(new Request('http://localhost/'), { env: { context: { ip, }, }, })
const info = getConnInfo(c)
expect(info.remote.address).toBe(ip) })
it('Should return undefined when context.ip is not present', () => { const c = new Context(new Request('http://localhost/'), { env: { context: {}, }, })
const info = getConnInfo(c)
expect(info.remote.address).toBeUndefined() })
it('Should return undefined when context is not present', () => { const c = new Context(new Request('http://localhost/'), { env: {}, })
const info = getConnInfo(c)
expect(info.remote.address).toBeUndefined() })})