import { describe, expect, it, run } from 'https://deno.land/x/tincan@1.0.1/mod.ts'
import { App } from '../../app.ts'
describe('Request properties', () => {
it.only('should have default HTTP Request properties', async () => {
const app = new App()
app.get('/', (req, res) => {
res.json({ url: req.url })
})
const listener = Deno.listen({ port: 8080, hostname: 'localhost' })
setTimeout(() => {
fetch(`http://localhost:8080`).then((res) => res.json()).then((json) => {
expect(json).toEqual({ url: `http://localhost:8080/` })
})
}, 0)
const conn = await listener.accept()
const requests = Deno.serveHttp(conn)
const { request, respondWith } = (await requests.nextRequest())!
const response = await app.handler(request, conn)
if (response) {
respondWith(response)
// Deno.close(conn.rid)
listener.close()
}
})
})
import { describe, expect, it, run } from 'https://deno.land/x/tincan@1.0.1/mod.ts'
import { App } from '../../app.ts'
describe('Request properties', () => {
it.only('should have default HTTP Request properties', async () => {
const app = new App()
app.get('/', (req, res) => {
res.json({ url: req.url })
})
const listener = Deno.listen({ port: 8080, hostname: 'localhost' })
setTimeout(() => {
fetch(`http://localhost:8080`).then((res) => res.json()).then((json) => {
expect(json).toEqual({ url: `http://localhost:8080/` })
})
}, 0)
const conn = await listener.accept()
const requests = Deno.serveHttp(conn)
const { request, respondWith } = (await requests.nextRequest())!
const response = await app.handler(request, conn)
if (response) {
respondWith(response)
// Deno.close(conn.rid)
listener.close()
}
})
})