diff options
author | 迷渡 <justjavac@gmail.com> | 2018-12-29 20:30:11 +0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-12-29 12:30:11 +0000 |
commit | 48e29c3c864b7b8c08bc1ab471342131bdde3c48 (patch) | |
tree | a4d898dd2bf02fdefd7b972dc5e4739ffa944210 /js/headers_test.ts | |
parent | 73fb98ce70b327d1236b9540f3839a89c5d22ef0 (diff) |
make `Headers` follow spec (#1427)
Diffstat (limited to 'js/headers_test.ts')
-rw-r--r-- | js/headers_test.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/js/headers_test.ts b/js/headers_test.ts index 9591b24f8..1433ba58e 100644 --- a/js/headers_test.ts +++ b/js/headers_test.ts @@ -224,11 +224,34 @@ test(function headerIllegalReject() { } catch (e) { errorCount++; } - assertEqual(errorCount, 8); + try { + headers.set("", "ok"); + } catch (e) { + errorCount++; + } + assertEqual(errorCount, 9); // 'o k' is valid value but invalid name new Headers({ "He-y": "o k" }); }); +// If pair does not contain exactly two items,then throw a TypeError. +test(function headerParamsShouldThrowTypeError() { + let hasThrown = 0; + + try { + new Headers(([["1"]] as unknown) as Array<[string, string]>); + hasThrown = 1; + } catch (err) { + if (err instanceof TypeError) { + hasThrown = 2; + } else { + hasThrown = 3; + } + } + + assertEqual(hasThrown, 2); +}); + test(function headerParamsArgumentsCheck() { const methodRequireOneParam = ["delete", "get", "has", "forEach"]; |