mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
make Headers
follow spec (#1427)
This commit is contained in:
parent
73fb98ce70
commit
48e29c3c86
2 changed files with 37 additions and 4 deletions
|
@ -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"];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue