-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.test.js
41 lines (38 loc) · 1.09 KB
/
main.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { assertEquals } from 'https://deno.land/[email protected]/assert/mod.ts'
import { main } from './main.js'
import { createHarness } from './test-utils.js'
Deno.test({
name: 'GET /',
async fn() {
const app = await main({
middleware: [
(app) => app.get('/foobar', (_req, res) => res.json({ ok: true })),
],
})
const harness = createHarness(app)
await harness.start()
.then(() =>
harness('/', { method: 'GET' }).then((res) => {
assertEquals(res.status, 200)
assertEquals(
res.headers.get('content-type'),
'application/json; charset=utf-8',
)
return res.body?.cancel()
})
)
.then(() =>
harness('/foobar', { method: 'GET' }).then((res) => {
assertEquals(res.status, 200)
assertEquals(
res.headers.get('content-type'),
'application/json; charset=utf-8',
)
return res.body?.cancel()
})
)
.finally(async () => await harness.stop())
},
sanitizeResources: false,
sanitizeOps: false,
})