Skip to content

Commit

Permalink
found
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldesigndj committed Jul 20, 2023
1 parent e2bc34f commit c6809a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/3_fetch_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { BASE_URL } from "@/utils/config.js"
import { Status } from "$std/http/http_status.ts"
import { freshTestWrapper } from "@/test/wrapper.ts"

// I am not sure this is a very good idea.

Deno.test(
"The homepage should work (200)",
{
Expand Down
33 changes: 33 additions & 0 deletions test/4_handler_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createHandler } from "$fresh/server.ts"
import manifest from "@/fresh.gen.ts"
import { assert, assertEquals } from "$std/testing/asserts.ts"
import { Status } from "$std/http/http_status.ts"

const CONN_INFO = {
localAddr: { hostname: "127.0.0.1", port: 8000, transport: "tcp" },
remoteAddr: { hostname: "127.0.0.1", port: 53496, transport: "tcp" },
}

// globalThis.document = new DOMParser().parseFromString(
// "<html></html>", // this the main change
// "text/html",
// )
// window.document = globalThis.document

Deno.test("HTTP assert test.", async (t) => {
const handler = await createHandler(manifest)

await t.step("#1 GET /", async () => {
const resp = await handler(new Request("http://127.0.0.1/"), CONN_INFO)
assertEquals(resp.status, Status.OK)
})

// await t.step("#3 GET /showcase", async () => {
// const resp = await handler(
// new Request("http://127.0.0.1/showcase"),
// CONN_INFO,
// )
// const text = await resp.text()
// assert(text.includes("<div>Hello Foo!</div>"))
// })
})

0 comments on commit c6809a0

Please sign in to comment.