Skip to content
Myr

fix: default content-type (#88)

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

* fix: default content-type * fixed for tests

authored by Yusuke Wada · committed by GitHub · parent b049cfa · Browse files · 2 files+6 added−6 removed
This commit

State

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

Diff stats

2 files+6 added−6 removed

  • tests:+3 added−3 removed
  • other:+3 added−3 removed

2 files+6 added−6 removed

modified:src/context.ts+3 added-3 removed
modified:test/context.test.ts+3 added-3 removed
5 unmodified lines
67 it('c.text()', async () => {8 const res = c.text('text in c', 201, { 'X-Custom': 'Message' })9 expect(res.status).toBe(201)10 expect(res.headers.get('Content-Type')).toBe('text/plain')10 expect(res.headers.get('Content-Type')).toBe('text/plain; charset=UTF-8')11 expect(await res.text()).toBe('text in c')12 expect(res.headers.get('X-Custom')).toBe('Message')13 })1415 it('c.json()', async () => {16 const res = c.json({ message: 'Hello' }, 201, { 'X-Custom': 'Message' })17 expect(res.status).toBe(201)18 expect(res.headers.get('Content-Type')).toMatch('application/json')18 expect(res.headers.get('Content-Type')).toMatch('application/json; charset=UTF-8')19 const text = await res.text()20 const object = JSON.parse(text)21 expect(object.message).toBe('Hello')22 expect(res.headers.get('X-Custom')).toBe('Message')
36 unmodified lines
59 c.statusText('Hono is Not Found')60 const res = c.json({ hono: 'great app' })61 expect(res.status).toBe(404)62 expect(res.statusText).toBe('Hono is Not Found')63 expect(res.headers.get('Content-Type')).toMatch(/json/)63 expect(res.headers.get('Content-Type')).toMatch('application/json; charset=UTF-8')64 const obj: { [key: string]: string } = await res.json()65 expect(obj['hono']).toBe('great app')66 })67
26 unmodified lines