summaryrefslogtreecommitdiff
path: root/js/fetch_test.ts
diff options
context:
space:
mode:
authorztplz <mysticzt@gmail.com>2018-10-20 00:12:36 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-10-19 12:12:36 -0400
commit7210e7b33b84382d4f418ab1be37fea85c2e1422 (patch)
treef7dcb6d486d3b451fc12c3357ff2e48e4dde3ab0 /js/fetch_test.ts
parent198fa31ec150b069dca39b94b2049d3ff65213e9 (diff)
Make fetch header compliant with the current spec (#1019)
Diffstat (limited to 'js/fetch_test.ts')
-rw-r--r--js/fetch_test.ts46
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));
+ }
+});