diff options
Diffstat (limited to 'js/fetch_test.ts')
-rw-r--r-- | js/fetch_test.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/fetch_test.ts b/js/fetch_test.ts index 7e2177350..2ef58f273 100644 --- a/js/fetch_test.ts +++ b/js/fetch_test.ts @@ -147,6 +147,41 @@ test(function headerGetSuccess() { } }); +test(function headerEntriesSuccess() { + const headers = new Headers(headerDict); + const iterators = headers.entries(); + assertEqual(Object.prototype.toString.call(iterators), "[object Iterator]"); + for (const it of iterators) { + const key = it[0]; + const value = it[1]; + assert(headers.has(key)); + assertEqual(value, headers.get(key)); + } +}); + +test(function headerKeysSuccess() { + const headers = new Headers(headerDict); + const iterators = headers.keys(); + assertEqual(Object.prototype.toString.call(iterators), "[object Iterator]"); + for (const it of iterators) { + assert(headers.has(it)); + } +}); + +test(function headerValuesSuccess() { + const headers = new Headers(headerDict); + const iterators = headers.values(); + const entries = headers.entries(); + const values = []; + for (const pair of entries) { + values.push(pair[1]); + } + assertEqual(Object.prototype.toString.call(iterators), "[object Iterator]"); + for (const it of iterators) { + assert(values.includes(it)); + } +}); + const headerEntriesDict = { name1: "value1", Name2: "value2", @@ -172,3 +207,14 @@ test(function headerForEachSuccess() { }); assertEqual(callNum, keys.length); }); + +test(function headerSymbolIteratorSuccess() { + assert(Symbol.iterator in Headers.prototype); + const headers = new Headers(headerEntriesDict); + for (const header of headers) { + const key = header[0]; + const value = header[1]; + assert(headers.has(key)); + assertEqual(value, headers.get(key)); + } +}); |