0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

chore(deno): use the latest jsr libraries for testing (#3375)

This commit is contained in:
ryu 2024-09-04 16:25:06 +09:00 committed by GitHub
parent a1b477ccf7
commit f9a23a9992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 37 additions and 22 deletions

View File

@ -12,6 +12,7 @@
"sloppy-imports"
],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3",
"hono/jsx/jsx-runtime": "../../src/jsx/jsx-runtime.ts"
}
}

View File

@ -12,6 +12,7 @@
"sloppy-imports"
],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.3",
"hono/jsx/jsx-runtime": "../../src/jsx/jsx-runtime.ts"
}
}

View File

@ -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>

View File

@ -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"
}
}
}

View File

@ -2,20 +2,33 @@
"version": "3",
"packages": {
"specifiers": {
"npm:@types/node": "npm:@types/node@18.16.19"
"jsr:@std/assert@^1.0.3": "jsr:@std/assert@1.0.3",
"jsr:@std/internal@^1.0.2": "jsr:@std/internal@1.0.2",
"jsr:@std/testing@^1.0.1": "jsr:@std/testing@1.0.1"
},
"npm": {
"@types/node@18.16.19": {
"integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==",
"dependencies": {}
"jsr": {
"@std/assert@1.0.3": {
"integrity": "b0d03ce1ced880df67132eea140623010d415848df66f6aa5df76507ca7c26d8",
"dependencies": [
"jsr:@std/internal@^1.0.2"
]
},
"@std/internal@1.0.2": {
"integrity": "f4cabe2021352e8bfc24e6569700df87bf070914fc38d4b23eddd20108ac4495"
},
"@std/testing@1.0.1": {
"integrity": "9c25841137ee818933e1722091bb9ed5fdc251c35e84c97979a52196bdb6c5c3",
"dependencies": [
"jsr:@std/assert@^1.0.3"
]
}
}
},
"remote": {
"https://deno.land/std@0.147.0/fmt/colors.ts": "6f9340b7fb8cc25a993a99e5efc56fe81bb5af284ff412129dd06df06f53c0b4",
"https://deno.land/std@0.147.0/testing/_diff.ts": "029a00560b0d534bc0046f1bce4bd36b3b41ada3f2a3178c85686eb2ff5f1413",
"https://deno.land/std@0.147.0/testing/_format.ts": "0d8dc79eab15b67cdc532826213bbe05bccfd276ca473a50a3fc7bbfb7260642",
"https://deno.land/std@0.147.0/testing/asserts.ts": "c17254748504f449c98476b78f4d206ca47cffc826e415026f09d7600c19535e",
"https://deno.land/std@0.147.0/testing/mock.ts": "d9630b551fe59a81b3c214c1a6ccb67819b6e34fc20e3424a659528fe1f572c1"
"remote": {},
"workspace": {
"dependencies": [
"jsr:@std/assert@^1.0.3",
"jsr:@std/testing@^1.0.1"
]
}
}

View File

@ -1,2 +0,0 @@
export { assert, assertEquals, assertMatch } from 'https://deno.land/std@0.147.0/testing/asserts.ts'
export { assertSpyCall, assertSpyCalls, spy } from 'https://deno.land/std@0.147.0/testing/mock.ts'

View File

@ -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.

View File

@ -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.

View File

@ -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()

View File

@ -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
})
@ -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))
@ -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
})