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
feat(adapters): add the seven adapters as workspace packages (#5463)Yusuke Wadabefore adoptionb877827
line 1why, one step back1import { Context } from 'hono'feat(adapters/netlify): publish to JSR (#5468)Yusuke Wadabefore adoption72f0d8d
line 2why, one step back2import { getConnInfo } from './conninfo.ts'feat(adapters): add the seven adapters as workspace packages (#5463)Yusuke Wadabefore adoptionb877827
lines 3–41why, one step back34describe('getConnInfo', () => {5 it('Should return the client IP from context.ip', () => {6 const ip = '203.0.113.50'7 const c = new Context(new Request('http://localhost/'), {8 env: {9 context: {10 ip,11 },12 },13 })1415 const info = getConnInfo(c)1617 expect(info.remote.address).toBe(ip)18 })1920 it('Should return undefined when context.ip is not present', () => {21 const c = new Context(new Request('http://localhost/'), {22 env: {23 context: {},24 },25 })2627 const info = getConnInfo(c)2829 expect(info.remote.address).toBeUndefined()30 })3132 it('Should return undefined when context is not present', () => {33 const c = new Context(new Request('http://localhost/'), {34 env: {},35 })3637 const info = getConnInfo(c)3839 expect(info.remote.address).toBeUndefined()40 })41})