diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/dts/lib.deno.shared_globals.d.ts | 169 | ||||
-rw-r--r-- | cli/tests/unit/fetch_test.ts | 7 | ||||
-rw-r--r-- | cli/tests/unit/form_data_test.ts | 2 | ||||
-rw-r--r-- | cli/tests/unit/request_test.ts | 19 |
4 files changed, 10 insertions, 187 deletions
diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts index 785650c82..52ad132f7 100644 --- a/cli/dts/lib.deno.shared_globals.d.ts +++ b/cli/dts/lib.deno.shared_globals.d.ts @@ -436,175 +436,6 @@ declare interface Crypto { ): T; } -declare class URLSearchParams { - constructor( - init?: string[][] | Record<string, string> | string | URLSearchParams, - ); - static toString(): string; - - /** Appends a specified key/value pair as a new search parameter. - * - * ```ts - * let searchParams = new URLSearchParams(); - * searchParams.append('name', 'first'); - * searchParams.append('name', 'second'); - * ``` - */ - append(name: string, value: string): void; - - /** Deletes the given search parameter and its associated value, - * from the list of all search parameters. - * - * ```ts - * let searchParams = new URLSearchParams([['name', 'value']]); - * searchParams.delete('name'); - * ``` - */ - delete(name: string): void; - - /** Returns all the values associated with a given search parameter - * as an array. - * - * ```ts - * searchParams.getAll('name'); - * ``` - */ - getAll(name: string): string[]; - - /** Returns the first value associated to the given search parameter. - * - * ```ts - * searchParams.get('name'); - * ``` - */ - get(name: string): string | null; - - /** Returns a Boolean that indicates whether a parameter with the - * specified name exists. - * - * ```ts - * searchParams.has('name'); - * ``` - */ - has(name: string): boolean; - - /** Sets the value associated with a given search parameter to the - * given value. If there were several matching values, this method - * deletes the others. If the search parameter doesn't exist, this - * method creates it. - * - * ```ts - * searchParams.set('name', 'value'); - * ``` - */ - set(name: string, value: string): void; - - /** Sort all key/value pairs contained in this object in place and - * return undefined. The sort order is according to Unicode code - * points of the keys. - * - * ```ts - * searchParams.sort(); - * ``` - */ - sort(): void; - - /** Calls a function for each element contained in this object in - * place and return undefined. Optionally accepts an object to use - * as this when executing callback as second argument. - * - * ```ts - * const params = new URLSearchParams([["a", "b"], ["c", "d"]]); - * params.forEach((value, key, parent) => { - * console.log(value, key, parent); - * }); - * ``` - * - */ - forEach( - callbackfn: (value: string, key: string, parent: this) => void, - thisArg?: any, - ): void; - - /** Returns an iterator allowing to go through all keys contained - * in this object. - * - * ```ts - * const params = new URLSearchParams([["a", "b"], ["c", "d"]]); - * for (const key of params.keys()) { - * console.log(key); - * } - * ``` - */ - keys(): IterableIterator<string>; - - /** Returns an iterator allowing to go through all values contained - * in this object. - * - * ```ts - * const params = new URLSearchParams([["a", "b"], ["c", "d"]]); - * for (const value of params.values()) { - * console.log(value); - * } - * ``` - */ - values(): IterableIterator<string>; - - /** Returns an iterator allowing to go through all key/value - * pairs contained in this object. - * - * ```ts - * const params = new URLSearchParams([["a", "b"], ["c", "d"]]); - * for (const [key, value] of params.entries()) { - * console.log(key, value); - * } - * ``` - */ - entries(): IterableIterator<[string, string]>; - - /** Returns an iterator allowing to go through all key/value - * pairs contained in this object. - * - * ```ts - * const params = new URLSearchParams([["a", "b"], ["c", "d"]]); - * for (const [key, value] of params) { - * console.log(key, value); - * } - * ``` - */ - [Symbol.iterator](): IterableIterator<[string, string]>; - - /** Returns a query string suitable for use in a URL. - * - * ```ts - * searchParams.toString(); - * ``` - */ - toString(): string; -} - -/** The URLÂ interface represents an object providing static methods used for creating object URLs. */ -declare class URL { - constructor(url: string, base?: string | URL); - createObjectURL(object: any): string; - revokeObjectURL(url: string): void; - - hash: string; - host: string; - hostname: string; - href: string; - toString(): string; - readonly origin: string; - password: string; - pathname: string; - port: string; - protocol: string; - search: string; - readonly searchParams: URLSearchParams; - username: string; - toJSON(): string; -} - interface MessageEventInit<T = any> extends EventInit { data?: T; origin?: string; diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts index a01b09d13..9776baa2f 100644 --- a/cli/tests/unit/fetch_test.ts +++ b/cli/tests/unit/fetch_test.ts @@ -108,10 +108,9 @@ unitTest({ perms: { net: true } }, async function fetchBodyUsed(): Promise< > { const response = await fetch("http://localhost:4545/cli/tests/fixture.json"); assertEquals(response.bodyUsed, false); - assertThrows((): void => { - // deno-lint-ignore no-explicit-any - (response as any).bodyUsed = true; - }); + // deno-lint-ignore no-explicit-any + (response as any).bodyUsed = true; + assertEquals(response.bodyUsed, false); await response.blob(); assertEquals(response.bodyUsed, true); }); diff --git a/cli/tests/unit/form_data_test.ts b/cli/tests/unit/form_data_test.ts index 76d137634..1a948631d 100644 --- a/cli/tests/unit/form_data_test.ts +++ b/cli/tests/unit/form_data_test.ts @@ -78,7 +78,7 @@ unitTest(function formDataParamsSetSuccess(): void { assertEquals(formData.get("e"), "null"); }); -unitTest(function fromDataUseDomFile(): void { +unitTest(function fromDataUseFile(): void { const formData = new FormData(); const file = new File(["foo"], "bar", { type: "text/plain", diff --git a/cli/tests/unit/request_test.ts b/cli/tests/unit/request_test.ts index 0214d99c3..a8cbed370 100644 --- a/cli/tests/unit/request_test.ts +++ b/cli/tests/unit/request_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, unitTest } from "./test_util.ts"; +import { assertEquals, unitTest } from "./test_util.ts"; -unitTest(function fromInit(): void { +unitTest(async function fromInit(): Promise<void> { const req = new Request("http://foo/", { body: "ahoyhoy", method: "POST", @@ -10,22 +10,18 @@ unitTest(function fromInit(): void { }, }); - // deno-lint-ignore no-explicit-any - assertEquals("ahoyhoy", (req as any)._bodySource); + assertEquals("ahoyhoy", await req.text()); assertEquals(req.url, "http://foo/"); assertEquals(req.headers.get("test-header"), "value"); }); -unitTest(function fromRequest(): void { - const r = new Request("http://foo/"); - // deno-lint-ignore no-explicit-any - (r as any)._bodySource = "ahoyhoy"; +unitTest(async function fromRequest(): Promise<void> { + const r = new Request("http://foo/", { body: "ahoyhoy" }); r.headers.set("test-header", "value"); const req = new Request(r); - // deno-lint-ignore no-explicit-any - assertEquals((req as any)._bodySource, (r as any)._bodySource); + assertEquals(await r.text(), await req.text()); assertEquals(req.url, r.url); assertEquals(req.headers.get("test-header"), r.headers.get("test-header")); }); @@ -65,7 +61,4 @@ unitTest(async function cloneRequestBodyStream(): Promise<void> { const b2 = await r2.text(); assertEquals(b1, b2); - - // deno-lint-ignore no-explicit-any - assert((r1 as any)._bodySource !== (r2 as any)._bodySource); }); |