Skip to content

Commit

Permalink
chore(deno): use the latest jsr libraries for testing (#3375)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuapp authored Sep 4, 2024
1 parent a1b477c commit f9a23a9
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 22 deletions.
1 change: 1 addition & 0 deletions runtime_tests/deno-jsx/deno.precompile.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"sloppy-imports"
],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3",
"hono/jsx/jsx-runtime": "../../src/jsx/jsx-runtime.ts"
}
}
1 change: 1 addition & 0 deletions runtime_tests/deno-jsx/deno.react-jsx.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"sloppy-imports"
],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3",
"hono/jsx/jsx-runtime": "../../src/jsx/jsx-runtime.ts"
}
}
2 changes: 1 addition & 1 deletion runtime_tests/deno-jsx/jsx.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Style, css } from '../../src/helper/css/index.ts'
import { Suspense, renderToReadableStream } from '../../src/jsx/streaming.ts'
import type { HtmlEscapedString } from '../../src/utils/html.ts'
import { HtmlEscapedCallbackPhase, resolveCallback } from '../../src/utils/html.ts'
import { assertEquals } from '../deno/deps.ts'
import { assertEquals } from '@std/assert'

Deno.test('JSX', () => {
const Component = ({ name }: { name: string }) => <span>{name}</span>
Expand Down
4 changes: 3 additions & 1 deletion runtime_tests/deno/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"sloppy-imports"
],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3",
"@std/testing": "jsr:@std/testing@^1.0.1",
"hono/jsx/jsx-runtime": "../../src/jsx/jsx-runtime.ts"
}
}
}
35 changes: 24 additions & 11 deletions runtime_tests/deno/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions runtime_tests/deno/deps.ts

This file was deleted.

2 changes: 1 addition & 1 deletion runtime_tests/deno/hono.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Context } from '../../src/context.ts'
import { env, getRuntimeKey } from '../../src/helper/adapter/index.ts'
import { Hono } from '../../src/hono.ts'
import { assertEquals } from './deps.ts'
import { assertEquals } from '@std/assert'

// Test just only minimal patterns.
// Because others are tested well in Cloudflare Workers environment already.
Expand Down
3 changes: 2 additions & 1 deletion runtime_tests/deno/middleware.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { serveStatic } from '../../src/adapter/deno/index.ts'
import { Hono } from '../../src/hono.ts'
import { basicAuth } from '../../src/middleware/basic-auth/index.ts'
import { jwt } from '../../src/middleware/jwt/index.ts'
import { assertEquals, assertMatch, assertSpyCall, assertSpyCalls, spy } from './deps.ts'
import { assertSpyCall, assertSpyCalls, spy } from '@std/testing/mock'
import { assertEquals, assertMatch } from '@std/assert'

// Test just only minimal patterns.
// Because others are already tested well in Cloudflare Workers environment.
Expand Down
2 changes: 1 addition & 1 deletion runtime_tests/deno/ssg.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toSSG } from '../../src/adapter/deno/ssg.ts'
import { Hono } from '../../src/hono.ts'
import { assertEquals } from '../deno/deps.ts'
import { assertEquals } from '@std/assert'

Deno.test('toSSG function', async () => {
const app = new Hono()
Expand Down
7 changes: 3 additions & 4 deletions runtime_tests/deno/stream.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Hono } from '../../src/hono.ts'
import { assertEquals } from './deps.ts'
import { stream, streamSSE } from '../../src/helper/streaming/index.ts'
import { assertEquals } from '@std/assert'

Deno.test('Shuld call onAbort via stream', async () => {
const app = new Hono()
let aborted = false
app.get('/stream', (c) => {
return stream(c, async (stream) => {
return stream(c, (stream) => {
stream.onAbort(() => {
aborted = true
})
Expand All @@ -21,7 +21,6 @@ Deno.test('Shuld call onAbort via stream', async () => {
const req = new Request(`http://localhost:${server.addr.port}/stream`, {
signal: ac.signal,
})
assertEquals
const res = fetch(req).catch(() => {})
assertEquals(aborted, false)
await new Promise((resolve) => setTimeout(resolve, 10))
Expand Down Expand Up @@ -59,7 +58,7 @@ Deno.test('Shuld call onAbort via streamSSE', async () => {
const app = new Hono()
let aborted = false
app.get('/stream', (c) => {
return streamSSE(c, async (stream) => {
return streamSSE(c, (stream) => {
stream.onAbort(() => {
aborted = true
})
Expand Down

0 comments on commit f9a23a9

Please sign in to comment.