Skip to content

Commit

Permalink
typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldesigndj committed Aug 16, 2023
1 parent c554158 commit b261e91
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions test/4_handler_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import { BASE_URL } from "@/utils/config.js"
import { assert, assertEquals } from "$std/assert/mod.ts"
import { Status } from "$std/http/http_status.ts"

const myTestWrapper = (args: any) => (theTests: any) => async (t: any) => {
const { serverProcess, lines } = await startFreshServer({
args,
})
await theTests(t)
// Stop the Server
await lines.cancel()
serverProcess.kill("SIGTERM")
// await for the server to close
await delay(100)
}
const myTestWrapper =
(args: string[]) => (theTests: any) => async (t: Deno.TestContext) => {
const { serverProcess, lines } = await startFreshServer({
args,
})
await theTests(t)
// Stop the Server
await lines.cancel()
serverProcess.kill("SIGTERM")
// await for the server to close
await delay(100)
}

export const fixtureTestWrapper = myTestWrapper([
"run",
Expand All @@ -35,8 +36,8 @@ Deno.test(
sanitizeResources: false,
sanitizeOps: false,
},
fixtureTestWrapper(async (t: any) => {
await t.step("The index page returns a 200 and 'Welcome'", async () => {
fixtureTestWrapper(async (t: Deno.TestContext) => {
await t.step("The index page returns a 200 and a 'Welcome'", async () => {
const response = await fetch(`${BASE_URL}`)
assertEquals(response.status, Status.OK)
const text = await response.text()
Expand Down

0 comments on commit b261e91

Please sign in to comment.