Skip to content

Commit

Permalink
test: add bun & deno tests for buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
askorupskyy committed Jan 8, 2025
1 parent 27c8cb6 commit a59e19c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions runtime-tests/bun/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,15 @@ describe('streaming', () => {
})
})
})

describe('Buffers', () => {
const app = new Hono().get('/', async (c) => {
return c.body(Buffer.from('hello'))
})

it('should allow returning buffers', async () => {
const res = await app.request(new Request('http://localhost/'))
expect(res.status).toBe(200)
expect(await res.text()).toBe('hello')
})
})
12 changes: 12 additions & 0 deletions runtime-tests/deno/hono.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Buffer } from 'node:buffer'

import { assertEquals } from '@std/assert'

Check failure on line 3 in runtime-tests/deno/hono.test.ts

View workflow job for this annotation

GitHub Actions / Main

`@std/assert` import should occur before import of `node:buffer`
import { Context } from '../../src/context.ts'
import { env, getRuntimeKey } from '../../src/helper/adapter/index.ts'
Expand Down Expand Up @@ -32,3 +34,13 @@ Deno.test('environment variables', () => {
const { NAME } = env<{ NAME: string }>(c)
assertEquals(NAME, 'Deno')
})

Deno.test('Buffers', async () => {
const app = new Hono().get('/', async (c) => {
return c.body(Buffer.from('hello'))
})

const res = await app.request('/')
assertEquals(res.status, 200)
assertEquals(await res.text(), 'hello')
})

0 comments on commit a59e19c

Please sign in to comment.