Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tsctx committed Feb 12, 2024
1 parent a7cd726 commit 740f1aa
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/fetch/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,21 @@ test('Headers as Iterable', async (t) => {

deepStrictEqual([...headers], expected)
})

await t.test('Headers iterator', (t) => {
const HeadersIteratorNext = Function.call.bind(Object.getPrototypeOf(new Headers()[Symbol.iterator]()).next)

const init = [
['a', '1'],
['b', '2']
]

const headers = new Headers(init)
const iterator = headers[Symbol.iterator]()
assert.deepStrictEqual(HeadersIteratorNext(iterator), { value: init[0], done: false })
assert.deepStrictEqual(HeadersIteratorNext(iterator), { value: init[1], done: false })
assert.deepStrictEqual(HeadersIteratorNext(iterator), { value: undefined, done: true })
})
})

test('arg validation', () => {
Expand Down

0 comments on commit 740f1aa

Please sign in to comment.