Skip to content

Commit 9b30474

Browse files
author
v1rtl
committed
add expect tests
1 parent 85f3e9f commit 9b30474

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

mod_test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,28 @@ describe('expectBody', () => {
113113
})
114114
})
115115

116+
describe('expect', () => {
117+
it('uses expectStatus if first arg is number', async () => {
118+
const handler: Handler = () => new Response('Hello World')
119+
const fetch = makeFetch(handler)
120+
const res = await fetch('/')
121+
res.expect(200)
122+
})
123+
it('uses expectHeader if two arguments', async () => {
124+
const handler: Handler = () =>
125+
new Response('Hello World', {
126+
'headers': { 'Content-Type': 'text/plain' },
127+
})
128+
const fetch = makeFetch(handler)
129+
const res = await fetch('/')
130+
res.expect('Content-Type', 'text/plain')
131+
})
132+
it('uses expectBody otherwise', async () => {
133+
const handler: Handler = () => new Response('Hello World')
134+
const fetch = makeFetch(handler)
135+
const res = await fetch('/')
136+
res.expect('Hello World')
137+
})
138+
})
139+
116140
run()

0 commit comments

Comments
 (0)