Skip to content

Commit 69f88dc

Browse files
author
v1rtl
committed
bring null comparison back
1 parent 23935e7 commit 69f88dc

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

mod.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ export const makeFetch = (h: HandlerOrListener) => {
8787
}
8888
const expectHeader = (a: string, b: string | RegExp | null | string[]) => {
8989
const header = res.headers.get(a)
90-
if (header === null) {
91-
throw new Error(`expected header ${header} to not be empty`)
92-
}
90+
9391
if (b instanceof RegExp) {
92+
if (header === null) {
93+
throw new Error(`expected header ${header} to not be empty`)
94+
}
9495
assertMatch(
9596
header,
9697
b,
@@ -99,6 +100,9 @@ export const makeFetch = (h: HandlerOrListener) => {
99100
} else if (
100101
Array.isArray(b)
101102
) {
103+
if (header === null) {
104+
throw new Error(`expected header ${header} to not be empty`)
105+
}
102106
assertEquals(
103107
header,
104108
b.join(','),
@@ -108,7 +112,7 @@ export const makeFetch = (h: HandlerOrListener) => {
108112
assertEquals(
109113
header,
110114
b,
111-
`expected to have header ${a} with value ${b}, got ${header}`,
115+
`expected to have header ${a} ${header === null ? 'empty' : 'with value ${b}, got ${header}'}`,
112116
)
113117
}
114118
return {

0 commit comments

Comments
 (0)