diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-04-19 01:00:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-19 01:00:13 +0200 |
commit | 0552eaf569ef910b0d132b6e60758f17a4519d91 (patch) | |
tree | 6fe6ff3755487475bcef60f3ddb7c8d42432494b /cli/tests/unit/dom_iterable_test.ts | |
parent | 0c5ecec8f60d4f1586e56b4e6e36ca973c555830 (diff) |
chore: align `Headers` to spec (#10199)
This commit aligns `Headers` to spec. It also removes the now unused
03_dom_iterable.js file. We now pass all relevant `Headers` WPT. We do
not implement any sort of header filtering, as we are a server side
runtime.
This is likely not the most efficient implementation of `Headers` yet.
It is however spec compliant. Once all the APIs in the `HTTP` hot loop
are correct we can start optimizing them. It is likely that this commit
reduces bench throughput temporarily.
Diffstat (limited to 'cli/tests/unit/dom_iterable_test.ts')
-rw-r--r-- | cli/tests/unit/dom_iterable_test.ts | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/cli/tests/unit/dom_iterable_test.ts b/cli/tests/unit/dom_iterable_test.ts deleted file mode 100644 index 4e94cfdba..000000000 --- a/cli/tests/unit/dom_iterable_test.ts +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -import { assert, assertEquals, unitTest } from "./test_util.ts"; - -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type -function setup() { - const dataSymbol = Symbol("data symbol"); - class Base { - [dataSymbol] = new Map<string, number>(); - - constructor( - data: Array<[string, number]> | IterableIterator<[string, number]>, - ) { - for (const [key, value] of data) { - this[dataSymbol].set(key, value); - } - } - } - - return { - Base, - // This is using an internal API we don't want published as types, so having - // to cast to any to "trick" TypeScript - // @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol - DomIterable: Deno[Deno.internal].DomIterableMixin(Base, dataSymbol), - }; -} - -unitTest(function testDomIterable(): void { - const { DomIterable, Base } = setup(); - - const fixture: Array<[string, number]> = [ - ["foo", 1], - ["bar", 2], - ]; - - const domIterable = new DomIterable(fixture); - - assertEquals(Array.from(domIterable.entries()), fixture); - assertEquals(Array.from(domIterable.values()), [1, 2]); - assertEquals(Array.from(domIterable.keys()), ["foo", "bar"]); - - let result: Array<[string, number]> = []; - for (const [key, value] of domIterable) { - assert(key != null); - assert(value != null); - result.push([key, value]); - } - assertEquals(fixture, result); - - result = []; - const scope = {}; - function callback( - this: typeof scope, - value: number, - key: string, - parent: typeof domIterable, - ): void { - assertEquals(parent, domIterable); - assert(key != null); - assert(value != null); - assert(this === scope); - result.push([key, value]); - } - domIterable.forEach(callback, scope); - assertEquals(fixture, result); - - assertEquals(DomIterable.name, Base.name); -}); - -unitTest(function testDomIterableScope(): void { - const { DomIterable } = setup(); - - const domIterable = new DomIterable([["foo", 1]]); - - // deno-lint-ignore no-explicit-any - function checkScope(thisArg: any, expected: any): void { - function callback(this: typeof thisArg): void { - assertEquals(this, expected); - } - domIterable.forEach(callback, thisArg); - } - - checkScope(0, Object(0)); - checkScope("", Object("")); - checkScope(null, window); - checkScope(undefined, window); -}); |