diff options
Diffstat (limited to 'cli/js/tests')
34 files changed, 238 insertions, 229 deletions
diff --git a/cli/js/tests/blob_test.ts b/cli/js/tests/blob_test.ts index 54071a11e..57793af0e 100644 --- a/cli/js/tests/blob_test.ts +++ b/cli/js/tests/blob_test.ts @@ -38,7 +38,7 @@ unitTest(function blobShouldNotThrowError(): void { try { const options1: object = { ending: "utf8", - hasOwnProperty: "hasOwnProperty" + hasOwnProperty: "hasOwnProperty", }; const options2: object = Object.create(null); new Blob(["Hello World"], options1); @@ -52,7 +52,7 @@ unitTest(function blobShouldNotThrowError(): void { unitTest(function nativeEndLine(): void { const options: object = { - ending: "native" + ending: "native", }; const blob = new Blob(["Hello\nWorld"], options); diff --git a/cli/js/tests/body_test.ts b/cli/js/tests/body_test.ts index 23f6d89e4..c8f783e04 100644 --- a/cli/js/tests/body_test.ts +++ b/cli/js/tests/body_test.ts @@ -5,7 +5,7 @@ import { unitTest, assertEquals, assert } from "./test_util.ts"; // eslint-disable-next-line @typescript-eslint/no-explicit-any function buildBody(body: any): Body { const stub = new Request("", { - body: body + body: body, }); return stub as Body; } @@ -19,7 +19,7 @@ const intArrays = [ Uint32Array, Uint8ClampedArray, Float32Array, - Float64Array + Float64Array, ]; unitTest(async function arrayBufferFromByteArrays(): Promise<void> { const buffer = new TextEncoder().encode("ahoyhoy8").buffer; diff --git a/cli/js/tests/buffer_test.ts b/cli/js/tests/buffer_test.ts index 163ed0a30..9cfb71669 100644 --- a/cli/js/tests/buffer_test.ts +++ b/cli/js/tests/buffer_test.ts @@ -7,7 +7,7 @@ import { assertEquals, assert, assertStrContains, - unitTest + unitTest, } from "./test_util.ts"; const { Buffer, readAll, readAllSync, writeAll, writeAllSync } = Deno; diff --git a/cli/js/tests/chmod_test.ts b/cli/js/tests/chmod_test.ts index e71e0bf26..8a534c701 100644 --- a/cli/js/tests/chmod_test.ts +++ b/cli/js/tests/chmod_test.ts @@ -22,7 +22,7 @@ unitTest( unitTest( { ignore: Deno.build.os === "win", - perms: { read: true, write: true } + perms: { read: true, write: true }, }, function chmodSyncSymlinkSuccess(): void { const enc = new TextEncoder(); @@ -94,7 +94,7 @@ unitTest( unitTest( { ignore: Deno.build.os === "win", - perms: { read: true, write: true } + perms: { read: true, write: true }, }, async function chmodSymlinkSuccess(): Promise<void> { const enc = new TextEncoder(); diff --git a/cli/js/tests/chown_test.ts b/cli/js/tests/chown_test.ts index f1847a08c..2d1dc7756 100644 --- a/cli/js/tests/chown_test.ts +++ b/cli/js/tests/chown_test.ts @@ -7,11 +7,11 @@ if (Deno.build.os !== "win") { // get the user ID and group ID of the current process const uidProc = Deno.run({ stdout: "piped", - cmd: ["python", "-c", "import os; print(os.getuid())"] + cmd: ["python", "-c", "import os; print(os.getuid())"], }); const gidProc = Deno.run({ stdout: "piped", - cmd: ["python", "-c", "import os; print(os.getgid())"] + cmd: ["python", "-c", "import os; print(os.getgid())"], }); assertEquals((await uidProc.status()).code, 0); diff --git a/cli/js/tests/console_test.ts b/cli/js/tests/console_test.ts index e571b02fb..b4848332f 100644 --- a/cli/js/tests/console_test.ts +++ b/cli/js/tests/console_test.ts @@ -6,14 +6,14 @@ import { assert, assertEquals, unitTest } from "./test_util.ts"; const { inspect, writeSync, - stdout + stdout, // eslint-disable-next-line @typescript-eslint/no-explicit-any } = Deno as any; const customInspect = Deno.symbols.customInspect; const { Console, - stringifyArgs + stringifyArgs, // @ts-ignore TypeScript (as of 3.7) does not support indexing namespaces by symbol } = Deno[Deno.symbols.internal]; @@ -37,7 +37,7 @@ unitTest(function consoleHasRightInstance(): void { }); unitTest(function consoleTestAssertShouldNotThrowError(): void { - mockConsole(console => { + mockConsole((console) => { console.assert(true); let hasThrown = undefined; try { @@ -92,7 +92,7 @@ unitTest(function consoleTestStringifyCircular(): void { arrowFunc: () => {}, extendedClass: new Extended(), nFunc: new Function(), - extendedCstr: Extended + extendedCstr: Extended, }; const circularObj = { @@ -105,7 +105,7 @@ unitTest(function consoleTestStringifyCircular(): void { nested: nestedObj, emptyObj: {}, arr: [1, "s", false, null, nestedObj], - baseClass: new Base() + baseClass: new Base(), }; nestedObj.o = circularObj; @@ -154,7 +154,7 @@ unitTest(function consoleTestStringifyCircular(): void { stringify( new Map([ [1, "one"], - [2, "two"] + [2, "two"], ]) ), `Map { 1 => "one", 2 => "two" }` @@ -192,7 +192,6 @@ unitTest(function consoleTestStringifyCircular(): void { assertEquals( stringify(console), `{ - printFunc: [Function], log: [Function], debug: [Function], info: [Function], @@ -261,8 +260,8 @@ unitTest(function consoleTestStringifyLargeObject(): void { g: 10, asd: 2, asda: 3, - x: { a: "asd", x: 3 } - } + x: { a: "asd", x: 3 }, + }, }; assertEquals( stringify(obj), @@ -394,14 +393,14 @@ unitTest(function consoleTestWithVariousOrInvalidFormatSpecifier(): void { unitTest(function consoleTestCallToStringOnLabel(): void { const methods = ["count", "countReset", "time", "timeLog", "timeEnd"]; - mockConsole(console => { + mockConsole((console) => { for (const method of methods) { let hasCalled = false; // @ts-ignore console[method]({ toString(): void { hasCalled = true; - } + }, }); assertEquals(hasCalled, true); } @@ -446,7 +445,7 @@ unitTest(function consoleTestClear(): void { // Test bound this issue unitTest(function consoleDetachedLog(): void { - mockConsole(console => { + mockConsole((console) => { const log = console.log; const dir = console.dir; const dirxml = console.dirxml; @@ -635,7 +634,7 @@ unitTest(function consoleTable(): void { console.table( new Map([ [1, "one"], - [2, "two"] + [2, "two"], ]) ); assertEquals( @@ -655,7 +654,7 @@ unitTest(function consoleTable(): void { b: { c: { d: 10 }, e: [1, 2, [5, 6]] }, f: "test", g: new Set([1, 2, 3, "test"]), - h: new Map([[1, "one"]]) + h: new Map([[1, "one"]]), }); assertEquals( out.toString(), @@ -677,7 +676,7 @@ unitTest(function consoleTable(): void { "test", false, { a: 10 }, - ["test", { b: 20, c: "test" }] + ["test", { b: 20, c: "test" }], ]); assertEquals( out.toString(), @@ -745,7 +744,7 @@ unitTest(function consoleTable(): void { // console.log(Error) test unitTest(function consoleLogShouldNotThrowError(): void { - mockConsole(console => { + mockConsole((console) => { let result = 0; try { console.log(new Error("foo")); diff --git a/cli/js/tests/custom_event_test.ts b/cli/js/tests/custom_event_test.ts index 7a5cc44ca..a8b2fcf88 100644 --- a/cli/js/tests/custom_event_test.ts +++ b/cli/js/tests/custom_event_test.ts @@ -7,7 +7,7 @@ unitTest(function customEventInitializedWithDetail(): void { const customEventInit = { bubbles: true, cancelable: true, - detail + detail, } as CustomEventInit; const event = new CustomEvent(type, customEventInit); diff --git a/cli/js/tests/dispatch_minimal_test.ts b/cli/js/tests/dispatch_minimal_test.ts index 60bb620db..afc17f4fb 100644 --- a/cli/js/tests/dispatch_minimal_test.ts +++ b/cli/js/tests/dispatch_minimal_test.ts @@ -3,7 +3,7 @@ import { assertEquals, assertMatch, unitTest, - unreachable + unreachable, } from "./test_util.ts"; const readErrorStackPattern = new RegExp( diff --git a/cli/js/tests/dom_iterable_test.ts b/cli/js/tests/dom_iterable_test.ts index e16378945..827a788a9 100644 --- a/cli/js/tests/dom_iterable_test.ts +++ b/cli/js/tests/dom_iterable_test.ts @@ -5,7 +5,7 @@ import { unitTest, assert, assertEquals } from "./test_util.ts"; function setup() { const dataSymbol = Symbol("data symbol"); class Base { - private [dataSymbol] = new Map<string, number>(); + [dataSymbol] = new Map<string, number>(); constructor( data: Array<[string, number]> | IterableIterator<[string, number]> @@ -21,7 +21,7 @@ function setup() { // This is using an internal API we don't want published as types, so having // to cast to any to "trick" TypeScript // @ts-ignore TypeScript (as of 3.7) does not support indexing namespaces by symbol - DomIterable: Deno[Deno.symbols.internal].DomIterableMixin(Base, dataSymbol) + DomIterable: Deno[Deno.symbols.internal].DomIterableMixin(Base, dataSymbol), }; } @@ -30,7 +30,7 @@ unitTest(function testDomIterable(): void { const fixture: Array<[string, number]> = [ ["foo", 1], - ["bar", 2] + ["bar", 2], ]; const domIterable = new DomIterable(fixture); diff --git a/cli/js/tests/error_stack_test.ts b/cli/js/tests/error_stack_test.ts index 7acbd3a3d..6868be215 100644 --- a/cli/js/tests/error_stack_test.ts +++ b/cli/js/tests/error_stack_test.ts @@ -76,7 +76,7 @@ function getMockCallSite( }, getPromiseIndex(): null { return null; - } + }, }; } @@ -90,7 +90,7 @@ unitTest(function prepareStackTrace(): void { structuredStackTrace: CallSite[] ) => string = MockError.prepareStackTrace; const result = prepareStackTrace(new Error("foo"), [ - getMockCallSite("CLI_SNAPSHOT.js", 23, 0) + getMockCallSite("CLI_SNAPSHOT.js", 23, 0), ]); assert(result.startsWith("Error: foo\n")); assert(result.includes(".ts:"), "should remap to something in 'js/'"); @@ -100,7 +100,7 @@ unitTest(function applySourceMap(): void { const result = Deno.applySourceMap({ filename: "CLI_SNAPSHOT.js", line: 23, - column: 0 + column: 0, }); assert(result.filename.endsWith(".ts")); assert(result.line != null); diff --git a/cli/js/tests/event_target_test.ts b/cli/js/tests/event_target_test.ts index 020db1acd..45f626502 100644 --- a/cli/js/tests/event_target_test.ts +++ b/cli/js/tests/event_target_test.ts @@ -114,7 +114,7 @@ unitTest(function dispatchEventShouldNotThrowError(): void { const target = new EventTarget(); const event = new Event("hasOwnProperty", { bubbles: true, - cancelable: false + cancelable: false, }); const listener = (): void => {}; target.addEventListener("hasOwnProperty", listener); @@ -130,7 +130,7 @@ unitTest(function eventTargetThisShouldDefaultToWindow(): void { const { addEventListener, dispatchEvent, - removeEventListener + removeEventListener, } = EventTarget.prototype; let n = 1; const event = new Event("hello"); @@ -164,7 +164,7 @@ unitTest(function eventTargetShouldAcceptEventListenerObject(): void { handleEvent(e: Event): void { assertEquals(e, event); ++callCount; - } + }, }; target.addEventListener("foo", listener); @@ -213,7 +213,7 @@ unitTest( handleEvent(e: Event): void { assertEquals(e, event); ++callCount; - } + }, }; target.addEventListener("foo", listener); diff --git a/cli/js/tests/fetch_test.ts b/cli/js/tests/fetch_test.ts index 67675177e..432ecd59c 100644 --- a/cli/js/tests/fetch_test.ts +++ b/cli/js/tests/fetch_test.ts @@ -5,7 +5,7 @@ import { assertEquals, assertStrContains, assertThrows, - fail + fail, } from "./test_util.ts"; unitTest({ perms: { net: true } }, async function fetchProtocolError(): Promise< @@ -174,7 +174,7 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function fetchWithRedirection(): Promise<void> { const response = await fetch("http://localhost:4546/"); // will redirect to http://localhost:4545/ @@ -188,7 +188,7 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function fetchWithRelativeRedirection(): Promise<void> { const response = await fetch("http://localhost:4545/cli/tests"); // will redirect to /cli/tests/ @@ -204,7 +204,7 @@ unitTest( // FIXME(bartlomieju): // The feature below is not implemented, but the test should work after implementation ignore: true, - perms: { net: true } + perms: { net: true }, }, async function fetchWithInfRedirection(): Promise<void> { const response = await fetch("http://localhost:4549/cli/tests"); // will redirect to the same place @@ -218,7 +218,7 @@ unitTest( const data = "Hello World"; const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: data + body: data, }); const text = await response.text(); assertEquals(text, data); @@ -232,7 +232,7 @@ unitTest( const data = "Hello World"; const req = new Request("http://localhost:4545/echo_server", { method: "POST", - body: data + body: data, }); const response = await fetch(req); const text = await response.text(); @@ -246,7 +246,7 @@ unitTest( const data = "Hello World"; const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: new TextEncoder().encode(data) + body: new TextEncoder().encode(data), }); const text = await response.text(); assertEquals(text, data); @@ -260,7 +260,7 @@ unitTest( const params = new URLSearchParams(data); const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: params + body: params, }); const text = await response.text(); assertEquals(text, data); @@ -277,11 +277,11 @@ unitTest({ perms: { net: true } }, async function fetchInitBlobBody(): Promise< > { const data = "const a = 1"; const blob = new Blob([data], { - type: "text/javascript" + type: "text/javascript", }); const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: blob + body: blob, }); const text = await response.text(); assertEquals(text, data); @@ -295,7 +295,7 @@ unitTest( form.append("field", "value"); const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: form + body: form, }); const resultForm = await response.formData(); assertEquals(form.get("field"), resultForm.get("field")); @@ -308,7 +308,7 @@ unitTest({ perms: { net: true } }, async function fetchUserAgent(): Promise< const data = "Hello World"; const response = await fetch("http://localhost:4545/echo_server", { method: "POST", - body: new TextEncoder().encode(data) + body: new TextEncoder().encode(data), }); assertEquals(response.headers.get("user-agent"), `Deno/${Deno.version.deno}`); await response.text(); @@ -337,7 +337,7 @@ function bufferServer(addr: string): Deno.Buffer { const [hostname, port] = addr.split(":"); const listener = Deno.listen({ hostname, - port: Number(port) + port: Number(port), }) as Deno.Listener; const buf = new Deno.Buffer(); listener.accept().then(async (conn: Deno.Conn) => { @@ -364,7 +364,7 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function fetchRequest(): Promise<void> { const addr = "127.0.0.1:4501"; @@ -373,8 +373,8 @@ unitTest( method: "POST", headers: [ ["Hello", "World"], - ["Foo", "Bar"] - ] + ["Foo", "Bar"], + ], }); assertEquals(response.status, 404); assertEquals(response.headers.get("Content-Length"), "2"); @@ -384,7 +384,7 @@ unitTest( "POST /blah HTTP/1.1\r\n", "hello: World\r\n", "foo: Bar\r\n", - `host: ${addr}\r\n\r\n` + `host: ${addr}\r\n\r\n`, ].join(""); assertEquals(actual, expected); } @@ -394,7 +394,7 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function fetchPostBodyString(): Promise<void> { const addr = "127.0.0.1:4502"; @@ -404,9 +404,9 @@ unitTest( method: "POST", headers: [ ["Hello", "World"], - ["Foo", "Bar"] + ["Foo", "Bar"], ], - body + body, }); assertEquals(response.status, 404); assertEquals(response.headers.get("Content-Length"), "2"); @@ -418,7 +418,7 @@ unitTest( "foo: Bar\r\n", `host: ${addr}\r\n`, `content-length: ${body.length}\r\n\r\n`, - body + body, ].join(""); assertEquals(actual, expected); } @@ -428,7 +428,7 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function fetchPostBodyTypedArray(): Promise<void> { const addr = "127.0.0.1:4503"; @@ -439,9 +439,9 @@ unitTest( method: "POST", headers: [ ["Hello", "World"], - ["Foo", "Bar"] + ["Foo", "Bar"], ], - body + body, }); assertEquals(response.status, 404); assertEquals(response.headers.get("Content-Length"), "2"); @@ -453,7 +453,7 @@ unitTest( "foo: Bar\r\n", `host: ${addr}\r\n`, `content-length: ${body.byteLength}\r\n\r\n`, - bodyStr + bodyStr, ].join(""); assertEquals(actual, expected); } @@ -461,11 +461,11 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function fetchWithManualRedirection(): Promise<void> { const response = await fetch("http://localhost:4546/", { - redirect: "manual" + redirect: "manual", }); // will redirect to http://localhost:4545/ assertEquals(response.status, 0); assertEquals(response.statusText, ""); @@ -484,11 +484,11 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function fetchWithErrorRedirection(): Promise<void> { const response = await fetch("http://localhost:4546/", { - redirect: "error" + redirect: "error", }); // will redirect to http://localhost:4545/ assertEquals(response.status, 0); assertEquals(response.statusText, ""); diff --git a/cli/js/tests/file_test.ts b/cli/js/tests/file_test.ts index 1a7a5f88b..4941554ad 100644 --- a/cli/js/tests/file_test.ts +++ b/cli/js/tests/file_test.ts @@ -58,7 +58,7 @@ unitTest(function fileVariousFileBits(): void { new Blob(), new Uint8Array([0x50, 0x41]), new Uint16Array([0x5353]), - new Uint32Array([0x53534150]) + new Uint32Array([0x53534150]), ], 16 ); diff --git a/cli/js/tests/files_test.ts b/cli/js/tests/files_test.ts index 39af460b8..f81ed3c47 100644 --- a/cli/js/tests/files_test.ts +++ b/cli/js/tests/files_test.ts @@ -3,7 +3,7 @@ import { unitTest, assert, assertEquals, - assertStrContains + assertStrContains, } from "./test_util.ts"; unitTest(function filesStdioFileDescriptors(): void { @@ -46,15 +46,17 @@ unitTest(async function readerToAsyncIterator(): Promise<void> { const encoder = new TextEncoder(); class TestReader implements Deno.Reader { - private offset = 0; - private buf = new Uint8Array(encoder.encode(this.s)); + #offset = 0; + #buf: Uint8Array; - constructor(private readonly s: string) {} + constructor(s: string) { + this.#buf = new Uint8Array(encoder.encode(s)); + } read(p: Uint8Array): Promise<number | Deno.EOF> { - const n = Math.min(p.byteLength, this.buf.byteLength - this.offset); - p.set(this.buf.slice(this.offset, this.offset + n)); - this.offset += n; + const n = Math.min(p.byteLength, this.#buf.byteLength - this.#offset); + p.set(this.#buf.slice(this.#offset, this.#offset + n)); + this.#offset += n; if (n === 0) { return Promise.resolve(Deno.EOF); @@ -76,14 +78,14 @@ unitTest(async function readerToAsyncIterator(): Promise<void> { unitTest( { - perms: { read: true, write: true } + perms: { read: true, write: true }, }, function openSyncMode(): void { const path = Deno.makeTempDirSync() + "/test_openSync.txt"; const file = Deno.openSync(path, { write: true, createNew: true, - mode: 0o626 + mode: 0o626, }); file.close(); const pathInfo = Deno.statSync(path); @@ -95,14 +97,14 @@ unitTest( unitTest( { - perms: { read: true, write: true } + perms: { read: true, write: true }, }, async function openMode(): Promise<void> { const path = (await Deno.makeTempDir()) + "/test_open.txt"; const file = await Deno.open(path, { write: true, createNew: true, - mode: 0o626 + mode: 0o626, }); file.close(); const pathInfo = Deno.statSync(path); @@ -198,7 +200,7 @@ unitTest( const w = { write: true, truncate: true, - create: true + create: true, }; const file = await Deno.open(filename, w); diff --git a/cli/js/tests/form_data_test.ts b/cli/js/tests/form_data_test.ts index 9b218547c..f51a51190 100644 --- a/cli/js/tests/form_data_test.ts +++ b/cli/js/tests/form_data_test.ts @@ -88,7 +88,7 @@ unitTest(function formDataSetEmptyBlobSuccess(): void { unitTest(function formDataParamsForEachSuccess(): void { const init = [ ["a", "54"], - ["b", "true"] + ["b", "true"], ]; const formData = new FormData(); for (const [name, value] of init) { @@ -110,7 +110,7 @@ unitTest(function formDataParamsArgumentsCheck(): void { "getAll", "get", "has", - "forEach" + "forEach", ] as const; const methodRequireTwoParams = ["append", "set"] as const; diff --git a/cli/js/tests/format_error_test.ts b/cli/js/tests/format_error_test.ts index 9831ef160..42c16b0c0 100644 --- a/cli/js/tests/format_error_test.ts +++ b/cli/js/tests/format_error_test.ts @@ -11,8 +11,8 @@ unitTest(function formatDiagnosticBasic() { scriptResourceName: "foo.ts", startColumn: 1, endColumn: 2, - code: 4000 - } + code: 4000, + }, ]; const out = Deno.formatDiagnostics(fixture); assert(out.includes("Example error")); diff --git a/cli/js/tests/headers_test.ts b/cli/js/tests/headers_test.ts index fcb5385a5..1ed58c9a4 100644 --- a/cli/js/tests/headers_test.ts +++ b/cli/js/tests/headers_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { unitTest, assert, assertEquals } from "./test_util.ts"; const { - stringifyArgs + stringifyArgs, // @ts-ignore TypeScript (as of 3.7) does not support indexing namespaces by symbol } = Deno[Deno.symbols.internal]; @@ -29,7 +29,7 @@ const headerDict: Record<string, string> = { name3: "value3", // @ts-ignore name4: undefined, - "Content-Type": "value4" + "Content-Type": "value4", }; // eslint-disable-next-line @typescript-eslint/no-explicit-any const headerSeq: any[] = []; @@ -142,7 +142,7 @@ const headerEntriesDict: Record<string, string> = { name: "value3", "content-Type": "value4", "Content-Typ": "value5", - "Content-Types": "value6" + "Content-Types": "value6", }; unitTest(function headerForEachSuccess(): void { @@ -346,7 +346,7 @@ unitTest(function customInspectReturnsCorrectHeadersFormat(): void { ); const multiParamHeader = new Headers([ ["Content-Type", "application/json"], - ["Content-Length", "1337"] + ["Content-Length", "1337"], ]); assertEquals( stringify(multiParamHeader), diff --git a/cli/js/tests/internals_test.ts b/cli/js/tests/internals_test.ts index fb712707c..b794bb5e8 100644 --- a/cli/js/tests/internals_test.ts +++ b/cli/js/tests/internals_test.ts @@ -3,7 +3,7 @@ import { unitTest, assert } from "./test_util.ts"; unitTest(function internalsExists(): void { const { - stringifyArgs + stringifyArgs, // @ts-ignore TypeScript (as of 3.7) does not support indexing namespaces by symbol } = Deno[Deno.symbols.internal]; assert(!!stringifyArgs); diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts index 2c077c102..6eb0f0dc6 100644 --- a/cli/js/tests/net_test.ts +++ b/cli/js/tests/net_test.ts @@ -3,7 +3,7 @@ import { unitTest, assert, assertEquals, - createResolvable + createResolvable, } from "./test_util.ts"; unitTest({ perms: { net: true } }, function netTcpListenClose(): void { @@ -18,13 +18,13 @@ unitTest( { perms: { net: true }, // TODO: - ignore: Deno.build.os === "win" + ignore: Deno.build.os === "win", }, function netUdpListenClose(): void { const socket = Deno.listen({ hostname: "127.0.0.1", port: 4500, - transport: "udp" + transport: "udp", }); assert(socket.addr.transport === "udp"); assertEquals(socket.addr.hostname, "127.0.0.1"); @@ -39,7 +39,7 @@ unitTest( const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ address: filePath, - transport: "unix" + transport: "unix", }); assert(socket.addr.transport === "unix"); assertEquals(socket.addr.address, filePath); @@ -53,7 +53,7 @@ unitTest( const filePath = Deno.makeTempFileSync(); const socket = Deno.listen({ address: filePath, - transport: "unixpacket" + transport: "unixpacket", }); assert(socket.addr.transport === "unixpacket"); assertEquals(socket.addr.address, filePath); @@ -63,7 +63,7 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function netTcpCloseWhileAccept(): Promise<void> { const listener = Deno.listen({ port: 4501 }); @@ -87,7 +87,7 @@ unitTest( const filePath = await Deno.makeTempFile(); const listener = Deno.listen({ address: filePath, - transport: "unix" + transport: "unix", }); const p = listener.accept(); listener.close(); @@ -337,7 +337,7 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function netListenAsyncIterator(): Promise<void> { const addr = { hostname: "127.0.0.1", port: 4500 }; @@ -372,14 +372,14 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function netCloseReadSuccess() { const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); const closeReadDeferred = createResolvable(); - listener.accept().then(async conn => { + listener.accept().then(async (conn) => { await closeReadDeferred; await conn.write(new Uint8Array([1, 2, 3])); const buf = new Uint8Array(1024); @@ -409,13 +409,13 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function netDoubleCloseRead() { const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); - listener.accept().then(async conn => { + listener.accept().then(async (conn) => { await conn.write(new Uint8Array([1, 2, 3])); await closeDeferred; conn.close(); @@ -441,13 +441,13 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function netCloseWriteSuccess() { const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); - listener.accept().then(async conn => { + listener.accept().then(async (conn) => { await conn.write(new Uint8Array([1, 2, 3])); await closeDeferred; conn.close(); @@ -480,13 +480,13 @@ unitTest( { // FIXME(bartlomieju) ignore: true, - perms: { net: true } + perms: { net: true }, }, async function netDoubleCloseWrite() { const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); - listener.accept().then(async conn => { + listener.accept().then(async (conn) => { await closeDeferred; conn.close(); }); @@ -509,7 +509,7 @@ unitTest( unitTest( { - perms: { net: true } + perms: { net: true }, }, async function netHangsOnClose() { let acceptedConn: Deno.Conn; diff --git a/cli/js/tests/os_test.ts b/cli/js/tests/os_test.ts index ef45d36fe..423cded50 100644 --- a/cli/js/tests/os_test.ts +++ b/cli/js/tests/os_test.ts @@ -4,7 +4,7 @@ import { assertEquals, assertNotEquals, assertThrows, - unitTest + unitTest, } from "./test_util.ts"; unitTest({ perms: { env: true } }, function envSuccess(): void { @@ -67,7 +67,7 @@ unitTest( const proc = Deno.run({ cmd: [Deno.execPath(), "eval", src], env: inputEnv, - stdout: "piped" + stdout: "piped", }); const status = await proc.status(); assertEquals(status.success, true); @@ -134,121 +134,121 @@ unitTest({ perms: { env: true } }, function getDir(): void { runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "cache", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "executable", runtime: [ { os: "mac", shouldHaveValue: false }, { os: "win", shouldHaveValue: false }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "data", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "data_local", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "audio", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "desktop", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "document", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "download", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "font", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: false }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "picture", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "public", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "template", runtime: [ { os: "mac", shouldHaveValue: false }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] + { os: "linux", shouldHaveValue: false }, + ], }, { kind: "tmp", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: true } - ] + { os: "linux", shouldHaveValue: true }, + ], }, { kind: "video", runtime: [ { os: "mac", shouldHaveValue: true }, { os: "win", shouldHaveValue: true }, - { os: "linux", shouldHaveValue: false } - ] - } + { os: "linux", shouldHaveValue: false }, + ], + }, ]; for (const s of scenes) { diff --git a/cli/js/tests/process_test.ts b/cli/js/tests/process_test.ts index 216b8a3bd..47efd86d5 100644 --- a/cli/js/tests/process_test.ts +++ b/cli/js/tests/process_test.ts @@ -3,7 +3,7 @@ import { assert, assertEquals, assertStrContains, - unitTest + unitTest, } from "./test_util.ts"; const { kill, run, readFile, open, makeTempDir, writeFile } = Deno; @@ -22,7 +22,7 @@ unitTest({ perms: { run: true } }, async function runSuccess(): Promise<void> { const p = run({ cmd: ["python", "-c", "print('hello world')"], stdout: "piped", - stderr: "null" + stderr: "null", }); const status = await p.status(); assertEquals(status.success, true); @@ -36,7 +36,7 @@ unitTest( { perms: { run: true } }, async function runCommandFailedWithCode(): Promise<void> { const p = run({ - cmd: ["python", "-c", "import sys;sys.exit(41 + 1)"] + cmd: ["python", "-c", "import sys;sys.exit(41 + 1)"], }); const status = await p.status(); assertEquals(status.success, false); @@ -50,11 +50,11 @@ unitTest( { // No signals on windows. ignore: Deno.build.os === "win", - perms: { run: true } + perms: { run: true }, }, async function runCommandFailedWithSignal(): Promise<void> { const p = run({ - cmd: ["python", "-c", "import os;os.kill(os.getpid(), 9)"] + cmd: ["python", "-c", "import os;os.kill(os.getpid(), 9)"], }); const status = await p.status(); assertEquals(status.success, false); @@ -102,7 +102,7 @@ while True: Deno.writeFileSync(`${cwd}/${pyProgramFile}.py`, enc.encode(pyProgram)); const p = run({ cwd, - cmd: ["python", `${pyProgramFile}.py`] + cmd: ["python", `${pyProgramFile}.py`], }); // Write the expected exit code *after* starting python. @@ -123,7 +123,7 @@ unitTest({ perms: { run: true } }, async function runStdinPiped(): Promise< > { const p = run({ cmd: ["python", "-c", "import sys; assert 'hello' == sys.stdin.read();"], - stdin: "piped" + stdin: "piped", }); assert(p.stdin); assert(!p.stdout); @@ -147,7 +147,7 @@ unitTest({ perms: { run: true } }, async function runStdoutPiped(): Promise< > { const p = run({ cmd: ["python", "-c", "import sys; sys.stdout.write('hello')"], - stdout: "piped" + stdout: "piped", }); assert(!p.stdin); assert(!p.stderr); @@ -176,7 +176,7 @@ unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise< > { const p = run({ cmd: ["python", "-c", "import sys; sys.stderr.write('hello')"], - stderr: "piped" + stderr: "piped", }); assert(!p.stdin); assert(!p.stdout); @@ -203,7 +203,7 @@ unitTest({ perms: { run: true } }, async function runStderrPiped(): Promise< unitTest({ perms: { run: true } }, async function runOutput(): Promise<void> { const p = run({ cmd: ["python", "-c", "import sys; sys.stdout.write('hello')"], - stdout: "piped" + stdout: "piped", }); const output = await p.output(); const s = new TextDecoder().decode(output); @@ -216,7 +216,7 @@ unitTest({ perms: { run: true } }, async function runStderrOutput(): Promise< > { const p = run({ cmd: ["python", "-c", "import sys; sys.stderr.write('error')"], - stderr: "piped" + stderr: "piped", }); const error = await p.stderrOutput(); const s = new TextDecoder().decode(error); @@ -235,10 +235,10 @@ unitTest( cmd: [ "python", "-c", - "import sys; sys.stderr.write('error\\n'); sys.stdout.write('output\\n');" + "import sys; sys.stderr.write('error\\n'); sys.stdout.write('output\\n');", ], stdout: file.rid, - stderr: file.rid + stderr: file.rid, }); await p.status(); @@ -265,7 +265,7 @@ unitTest( const p = run({ cmd: ["python", "-c", "import sys; assert 'hello' == sys.stdin.read();"], - stdin: file.rid + stdin: file.rid, }); const status = await p.status(); @@ -280,13 +280,13 @@ unitTest({ perms: { run: true } }, async function runEnv(): Promise<void> { cmd: [ "python", "-c", - "import os, sys; sys.stdout.write(os.environ.get('FOO', '') + os.environ.get('BAR', ''))" + "import os, sys; sys.stdout.write(os.environ.get('FOO', '') + os.environ.get('BAR', ''))", ], env: { FOO: "0123", - BAR: "4567" + BAR: "4567", }, - stdout: "piped" + stdout: "piped", }); const output = await p.output(); const s = new TextDecoder().decode(output); @@ -299,9 +299,9 @@ unitTest({ perms: { run: true } }, async function runClose(): Promise<void> { cmd: [ "python", "-c", - "from time import sleep; import sys; sleep(10000); sys.stderr.write('error')" + "from time import sleep; import sys; sleep(10000); sys.stderr.write('error')", ], - stderr: "piped" + stderr: "piped", }); assert(!p.stdin); assert(!p.stdout); @@ -343,7 +343,7 @@ if (Deno.build.os !== "win") { void > { const p = run({ - cmd: ["python", "-c", "from time import sleep; sleep(10000)"] + cmd: ["python", "-c", "from time import sleep; sleep(10000)"], }); assertEquals(Deno.Signal.SIGINT, 2); @@ -361,7 +361,7 @@ if (Deno.build.os !== "win") { unitTest({ perms: { run: true } }, function killFailed(): void { const p = run({ - cmd: ["python", "-c", "from time import sleep; sleep(10000)"] + cmd: ["python", "-c", "from time import sleep; sleep(10000)"], }); assert(!p.stdin); assert(!p.stdout); diff --git a/cli/js/tests/realpath_test.ts b/cli/js/tests/realpath_test.ts index d185e4095..7725a3aa8 100644 --- a/cli/js/tests/realpath_test.ts +++ b/cli/js/tests/realpath_test.ts @@ -15,7 +15,7 @@ unitTest({ perms: { read: true } }, function realpathSyncSuccess(): void { unitTest( { ignore: Deno.build.os === "win", - perms: { read: true, write: true } + perms: { read: true, write: true }, }, function realpathSyncSymlink(): void { const testDir = Deno.makeTempDirSync(); @@ -67,7 +67,7 @@ unitTest({ perms: { read: true } }, async function realpathSuccess(): Promise< unitTest( { ignore: Deno.build.os === "win", - perms: { read: true, write: true } + perms: { read: true, write: true }, }, async function realpathSymlink(): Promise<void> { const testDir = Deno.makeTempDirSync(); diff --git a/cli/js/tests/request_test.ts b/cli/js/tests/request_test.ts index 15e19e285..8a276c5e7 100644 --- a/cli/js/tests/request_test.ts +++ b/cli/js/tests/request_test.ts @@ -6,8 +6,8 @@ unitTest(function fromInit(): void { body: "ahoyhoy", method: "POST", headers: { - "test-header": "value" - } + "test-header": "value", + }, }); // @ts-ignore @@ -34,7 +34,7 @@ unitTest(async function cloneRequestBodyStream(): Promise<void> { // hack to get a stream const stream = new Request("", { body: "a test body" }).body; const r1 = new Request("https://example.com", { - body: stream + body: stream, }); const r2 = r1.clone(); diff --git a/cli/js/tests/signal_test.ts b/cli/js/tests/signal_test.ts index c966e696b..a51df09d7 100644 --- a/cli/js/tests/signal_test.ts +++ b/cli/js/tests/signal_test.ts @@ -4,7 +4,7 @@ import { assert, assertEquals, assertThrows, - createResolvable + createResolvable, } from "./test_util.ts"; function defer(n: number): Promise<void> { diff --git a/cli/js/tests/test_util.ts b/cli/js/tests/test_util.ts index 980d32bac..da2e917f8 100644 --- a/cli/js/tests/test_util.ts +++ b/cli/js/tests/test_util.ts @@ -10,7 +10,7 @@ export { assertStrictEq, assertStrContains, unreachable, - fail + fail, } from "../../../std/testing/asserts.ts"; export { readLines } from "../../../std/io/bufio.ts"; export { parse as parseArgs } from "../../../std/flags/mod.ts"; @@ -28,7 +28,7 @@ export interface Permissions { export function fmtPerms(perms: Permissions): string { const p = Object.keys(perms) .filter((e): boolean => perms[e as keyof Permissions] === true) - .map(key => `--allow-${key}`); + .map((key) => `--allow-${key}`); if (p.length) { return p.join(" "); @@ -48,7 +48,7 @@ export async function getProcessPermissions(): Promise<Permissions> { net: await isGranted("net"), env: await isGranted("env"), plugin: await isGranted("plugin"), - hrtime: await isGranted("hrtime") + hrtime: await isGranted("hrtime"), }; } @@ -108,7 +108,7 @@ function normalizeTestPermissions(perms: UnitTestPermissions): Permissions { run: !!perms.run, env: !!perms.env, plugin: !!perms.plugin, - hrtime: !!perms.hrtime + hrtime: !!perms.hrtime, }; } @@ -170,7 +170,7 @@ export function unitTest( name, fn, ignore: !!options.ignore, - perms: normalizedPerms + perms: normalizedPerms, }; REGISTERED_UNIT_TESTS.push(unitTestDefinition); @@ -194,17 +194,19 @@ export function createResolvable<T>(): Resolvable<T> { return Object.assign(promise, methods!) as Resolvable<T>; } +const encoder = new TextEncoder(); + export class SocketReporter implements Deno.TestReporter { - private encoder: TextEncoder; + #conn: Deno.Conn; - constructor(private conn: Deno.Conn) { - this.encoder = new TextEncoder(); + constructor(conn: Deno.Conn) { + this.#conn = conn; } // eslint-disable-next-line @typescript-eslint/no-explicit-any async write(msg: any): Promise<void> { - const encodedMsg = this.encoder.encode(JSON.stringify(msg) + "\n"); - await Deno.writeAll(this.conn, encodedMsg); + const encodedMsg = encoder.encode(JSON.stringify(msg) + "\n"); + await Deno.writeAll(this.#conn, encodedMsg); } async start(msg: Deno.TestEventStart): Promise<void> { @@ -229,9 +231,9 @@ export class SocketReporter implements Deno.TestReporter { } async end(msg: Deno.TestEventEnd): Promise<void> { - const encodedMsg = this.encoder.encode(JSON.stringify(msg)); - await Deno.writeAll(this.conn, encodedMsg); - this.conn.closeWrite(); + const encodedMsg = encoder.encode(JSON.stringify(msg)); + await Deno.writeAll(this.#conn, encodedMsg); + this.#conn.closeWrite(); } } @@ -245,7 +247,7 @@ unitTest(function permissionsMatches(): void { env: false, run: false, plugin: false, - hrtime: false + hrtime: false, }, normalizeTestPermissions({ read: true }) ) @@ -260,7 +262,7 @@ unitTest(function permissionsMatches(): void { env: false, run: false, plugin: false, - hrtime: false + hrtime: false, }, normalizeTestPermissions({}) ) @@ -275,7 +277,7 @@ unitTest(function permissionsMatches(): void { env: true, run: true, plugin: true, - hrtime: true + hrtime: true, }, normalizeTestPermissions({ read: true }) ), @@ -291,7 +293,7 @@ unitTest(function permissionsMatches(): void { env: false, run: false, plugin: false, - hrtime: false + hrtime: false, }, normalizeTestPermissions({ read: true }) ), @@ -307,7 +309,7 @@ unitTest(function permissionsMatches(): void { env: true, run: true, plugin: true, - hrtime: true + hrtime: true, }, { read: true, @@ -316,7 +318,7 @@ unitTest(function permissionsMatches(): void { env: true, run: true, plugin: true, - hrtime: true + hrtime: true, } ) ); @@ -330,9 +332,9 @@ unitTest( { perms: { read: true } }, function assertAllUnitTestFilesImported(): void { const directoryTestFiles = Deno.readdirSync("./cli/js/tests/") - .map(k => k.name) + .map((k) => k.name) .filter( - file => + (file) => file!.endsWith(".ts") && !file!.endsWith("unit_tests.ts") && !file!.endsWith("test_util.ts") && @@ -344,12 +346,12 @@ unitTest( const importLines = new TextDecoder("utf-8") .decode(unitTestsFile) .split("\n") - .filter(line => line.startsWith("import")); + .filter((line) => line.startsWith("import")); const importedTestFiles = importLines.map( - relativeFilePath => relativeFilePath.match(/\/([^\/]+)";/)![1] + (relativeFilePath) => relativeFilePath.match(/\/([^\/]+)";/)![1] ); - directoryTestFiles.forEach(dirFile => { + directoryTestFiles.forEach((dirFile) => { if (!importedTestFiles.includes(dirFile!)) { throw new Error( "cil/js/tests/unit_tests.ts is missing import of test file: cli/js/" + diff --git a/cli/js/tests/testing_test.ts b/cli/js/tests/testing_test.ts index 9ed89f532..09378ec30 100644 --- a/cli/js/tests/testing_test.ts +++ b/cli/js/tests/testing_test.ts @@ -18,7 +18,7 @@ unitTest(function nameOfTestCaseCantBeEmpty(): void { () => { Deno.test({ name: "", - fn: () => {} + fn: () => {}, }); }, TypeError, @@ -29,7 +29,7 @@ unitTest(function nameOfTestCaseCantBeEmpty(): void { unitTest(function testFnCantBeAnonymous(): void { assertThrows( () => { - Deno.test(function() {}); + Deno.test(function () {}); }, TypeError, "The test function can't be anonymous" diff --git a/cli/js/tests/text_encoding_test.ts b/cli/js/tests/text_encoding_test.ts index e85655feb..c8a7fbe42 100644 --- a/cli/js/tests/text_encoding_test.ts +++ b/cli/js/tests/text_encoding_test.ts @@ -21,7 +21,7 @@ unitTest(function atobWithAsciiWhitespace(): void { "aGVsbG8gd29ybGQ=\n", "aGVsbG\t8gd29ybGQ=", `aGVsbG\t8g - d29ybGQ=` + d29ybGQ=`, ]; for (const encoded of encodedList) { diff --git a/cli/js/tests/timers_test.ts b/cli/js/tests/timers_test.ts index f758d5fca..7adff0095 100644 --- a/cli/js/tests/timers_test.ts +++ b/cli/js/tests/timers_test.ts @@ -4,7 +4,7 @@ import { createResolvable, assert, assertEquals, - assertNotEquals + assertNotEquals, } from "./test_util.ts"; function deferred(): { @@ -23,7 +23,7 @@ function deferred(): { return { promise, resolve: resolve!, - reject: reject! + reject: reject!, }; } @@ -180,7 +180,7 @@ unitTest(async function timeoutCallbackThis(): Promise<void> { foo(): void { assertEquals(this, window); resolve(); - } + }, }; setTimeout(obj.foo, 1); await promise; @@ -198,7 +198,7 @@ unitTest(async function timeoutBindThis(): Promise<void> { [], "foo", (): void => {}, - Object.prototype + Object.prototype, ]; for (const thisArg of thisCheckPassed) { @@ -240,7 +240,7 @@ unitTest(function clearTimeoutShouldConvertToNumber(): void { valueOf(): number { called = true; return 1; - } + }, }; clearTimeout((obj as unknown) as number); assert(called); diff --git a/cli/js/tests/tls_test.ts b/cli/js/tests/tls_test.ts index 20dd62f9b..019b81652 100644 --- a/cli/js/tests/tls_test.ts +++ b/cli/js/tests/tls_test.ts @@ -3,7 +3,7 @@ import { assert, assertEquals, createResolvable, - unitTest + unitTest, } from "./test_util.ts"; import { BufWriter, BufReader } from "../../../std/io/bufio.ts"; import { TextProtoReader } from "../../../std/textproto/mod.ts"; @@ -28,7 +28,7 @@ unitTest(async function connectTLSCertFileNoReadPerm(): Promise<void> { await Deno.connectTLS({ hostname: "github.com", port: 443, - certFile: "cli/tests/tls/RootCA.crt" + certFile: "cli/tests/tls/RootCA.crt", }); } catch (e) { err = e; @@ -45,13 +45,13 @@ unitTest( hostname: "localhost", port: 4500, certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key" + keyFile: "cli/tests/tls/localhost.key", }; try { Deno.listenTLS({ ...options, - certFile: "./non/existent/file" + certFile: "./non/existent/file", }); } catch (e) { err = e; @@ -61,7 +61,7 @@ unitTest( try { Deno.listenTLS({ ...options, - keyFile: "./non/existent/file" + keyFile: "./non/existent/file", }); } catch (e) { err = e; @@ -77,7 +77,7 @@ unitTest({ perms: { net: true } }, function listenTLSNoReadPerm(): void { hostname: "localhost", port: 4500, certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key" + keyFile: "cli/tests/tls/localhost.key", }); } catch (e) { err = e; @@ -88,7 +88,7 @@ unitTest({ perms: { net: true } }, function listenTLSNoReadPerm(): void { unitTest( { - perms: { read: true, write: true, net: true } + perms: { read: true, write: true, net: true }, }, function listenTLSEmptyKeyFile(): void { let err; @@ -96,19 +96,19 @@ unitTest( hostname: "localhost", port: 4500, certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key" + keyFile: "cli/tests/tls/localhost.key", }; const testDir = Deno.makeTempDirSync(); const keyFilename = testDir + "/key.pem"; Deno.writeFileSync(keyFilename, new Uint8Array([]), { - mode: 0o666 + mode: 0o666, }); try { Deno.listenTLS({ ...options, - keyFile: keyFilename + keyFile: keyFilename, }); } catch (e) { err = e; @@ -125,19 +125,19 @@ unitTest( hostname: "localhost", port: 4500, certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key" + keyFile: "cli/tests/tls/localhost.key", }; const testDir = Deno.makeTempDirSync(); const certFilename = testDir + "/cert.crt"; Deno.writeFileSync(certFilename, new Uint8Array([]), { - mode: 0o666 + mode: 0o666, }); try { Deno.listenTLS({ ...options, - certFile: certFilename + certFile: certFilename, }); } catch (e) { err = e; @@ -157,7 +157,7 @@ unitTest( hostname, port, certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key" + keyFile: "cli/tests/tls/localhost.key", }); const response = encoder.encode( @@ -180,7 +180,7 @@ unitTest( const conn = await Deno.connectTLS({ hostname, port, - certFile: "cli/tests/tls/RootCA.pem" + certFile: "cli/tests/tls/RootCA.pem", }); assert(conn.rid > 0); const w = new BufWriter(conn); diff --git a/cli/js/tests/umask_test.ts b/cli/js/tests/umask_test.ts index e4576c515..71a5e71f8 100644 --- a/cli/js/tests/umask_test.ts +++ b/cli/js/tests/umask_test.ts @@ -3,7 +3,7 @@ import { unitTest, assertEquals } from "./test_util.ts"; unitTest( { - ignore: Deno.build.os === "win" + ignore: Deno.build.os === "win", }, function umaskSuccess(): void { const prevMask = Deno.umask(0o020); diff --git a/cli/js/tests/unit_test_runner.ts b/cli/js/tests/unit_test_runner.ts index e79e1b7ea..8d3eaa4f5 100755 --- a/cli/js/tests/unit_test_runner.ts +++ b/cli/js/tests/unit_test_runner.ts @@ -8,7 +8,7 @@ import { registerUnitTests, SocketReporter, fmtPerms, - parseArgs + parseArgs, } from "./test_util.ts"; interface PermissionSetTestResult { @@ -27,7 +27,7 @@ const PERMISSIONS: Deno.PermissionName[] = [ "env", "run", "plugin", - "hrtime" + "hrtime", ]; /** @@ -69,7 +69,7 @@ async function workerRunnerMain( failFast: false, exitOnFail: false, reporter: socketReporter, - only: filter + only: filter, }); } @@ -93,7 +93,7 @@ function spawnWorkerRunner( "cli/js/tests/unit_test_runner.ts", "--worker", `--addr=${addr}`, - `--perms=${permStr}` + `--perms=${permStr}`, ]; if (filter) { @@ -107,7 +107,7 @@ function spawnWorkerRunner( cmd, stdin: ioMode, stdout: ioMode, - stderr: ioMode + stderr: ioMode, }); return p; @@ -177,7 +177,7 @@ async function runTestsForPermissionSet( permsStr: permsFmt, duration: endEvent.duration, stats: endEvent.stats, - results: endEvent.results + results: endEvent.results, }; } @@ -223,7 +223,7 @@ async function masterRunnerMain( kind: Deno.TestEvent.End, stats, duration, - results + results, }); testsPassed = testsPassed && testResult.passed; } @@ -288,7 +288,7 @@ function assertOrHelp(expr: unknown): asserts expr { async function main(): Promise<void> { const args = parseArgs(Deno.args, { boolean: ["master", "worker", "verbose"], - "--": true + "--": true, }); if (args.help) { @@ -315,7 +315,7 @@ async function main(): Promise<void> { await Deno.runTests({ failFast: false, exitOnFail: true, - only: filter + only: filter, }); } diff --git a/cli/js/tests/url_search_params_test.ts b/cli/js/tests/url_search_params_test.ts index b256395a0..3e71d2900 100644 --- a/cli/js/tests/url_search_params_test.ts +++ b/cli/js/tests/url_search_params_test.ts @@ -13,7 +13,7 @@ unitTest(function urlSearchParamsInitString(): void { unitTest(function urlSearchParamsInitIterable(): void { const init = [ ["a", "54"], - ["b", "true"] + ["b", "true"], ]; const searchParams = new URLSearchParams(init); assertEquals(searchParams.toString(), "a=54&b=true"); @@ -94,7 +94,7 @@ unitTest(function urlSearchParamsSortSuccess(): void { unitTest(function urlSearchParamsForEachSuccess(): void { const init = [ ["a", "54"], - ["b", "true"] + ["b", "true"], ]; const searchParams = new URLSearchParams(init); let callNum = 0; @@ -225,7 +225,7 @@ unitTest(function urlSearchParamsDeletingAppendedMultiple(): void { // ref: https://github.com/web-platform-tests/wpt/blob/master/url/urlsearchparams-constructor.any.js#L176-L182 unitTest(function urlSearchParamsCustomSymbolIterator(): void { const params = new URLSearchParams(); - params[Symbol.iterator] = function*(): IterableIterator<[string, string]> { + params[Symbol.iterator] = function* (): IterableIterator<[string, string]> { yield ["a", "b"]; }; const params1 = new URLSearchParams((params as unknown) as string[][]); @@ -236,7 +236,7 @@ unitTest( function urlSearchParamsCustomSymbolIteratorWithNonStringParams(): void { const params = {}; // @ts-ignore - params[Symbol.iterator] = function*(): IterableIterator<[number, number]> { + params[Symbol.iterator] = function* (): IterableIterator<[number, number]> { yield [1, 2]; }; const params1 = new URLSearchParams((params as unknown) as string[][]); diff --git a/cli/js/tests/url_test.ts b/cli/js/tests/url_test.ts index 5b3067e4b..e1b2d47bd 100644 --- a/cli/js/tests/url_test.ts +++ b/cli/js/tests/url_test.ts @@ -98,6 +98,12 @@ unitTest(function urlModifyHref(): void { assertEquals(url.hash, "#qux"); }); +unitTest(function urlNormalize(): void { + const url = new URL("http://example.com"); + assertEquals(url.pathname, "/"); + assertEquals(url.href, "http://example.com/"); +}); + unitTest(function urlModifyPathname(): void { const url = new URL("http://foo.bar/baz%qat/qux%quux"); assertEquals(url.pathname, "/baz%qat/qux%quux"); @@ -183,7 +189,7 @@ unitTest(function sortingNonExistentParamRemovesQuestionMarkFromURL(): void { unitTest( { // FIXME(bartlomieju) - ignore: true + ignore: true, }, function customInspectFunction(): void { const url = new URL("http://example.com/?"); diff --git a/cli/js/tests/utime_test.ts b/cli/js/tests/utime_test.ts index 8cd34d39a..917b8b8b6 100644 --- a/cli/js/tests/utime_test.ts +++ b/cli/js/tests/utime_test.ts @@ -15,7 +15,7 @@ unitTest( const testDir = Deno.makeTempDirSync(); const filename = testDir + "/file.txt"; Deno.writeFileSync(filename, new TextEncoder().encode("hello"), { - mode: 0o666 + mode: 0o666, }); const atime = 1000; @@ -115,7 +115,7 @@ unitTest( const testDir = Deno.makeTempDirSync(); const filename = testDir + "/file.txt"; Deno.writeFileSync(filename, new TextEncoder().encode("hello"), { - mode: 0o666 + mode: 0o666, }); const atime = 1000; |