homeman-deno/tests/main_test.ts
2024-01-27 14:31:03 -06:00

24 lines
712 B
TypeScript

import { createHandler, ServeHandlerInfo } from '$fresh/server.ts'
import manifest from '@homeman/fresh.gen.ts'
import config from '@homeman/fresh.config.ts'
import { assert, assertEquals } from '$std/assert/mod.ts'
const hostname = '127.0.0.1'
const port = 53496
const CONN_INFO: ServeHandlerInfo = {
remoteAddr: { hostname, port, transport: 'tcp' },
}
Deno.test('HTTP assert test.', async (t) => {
const handler = await createHandler(manifest, config)
await t.step('#1 GET /', async () => {
const resp = await handler(new Request(`http://${hostname}/`), CONN_INFO)
const body = await resp.text()
assertEquals(resp.status, 200)
assert(body.includes('Fam'))
assert(body.includes('Flan'))
})
})