diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-04-28 12:33:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 12:33:09 +0200 |
commit | 8feb30e3258ed9690eb850e3ca22842b260a0403 (patch) | |
tree | 6805bfe3df675c2c7f6a379093061c6b73d8365a /cli/js | |
parent | b508e845671de9351c3f51755647371d76128d29 (diff) |
BREAKING: remove overload of Deno.test() (#4951)
This commit removes overload of Deno.test() that accepted named
function.
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/lib.deno.ns.d.ts | 18 | ||||
-rw-r--r-- | cli/js/testing.ts | 8 | ||||
-rw-r--r-- | cli/js/tests/testing_test.ts | 10 |
3 files changed, 1 insertions, 35 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts index 4d06d07e4..a421b46aa 100644 --- a/cli/js/lib.deno.ns.d.ts +++ b/cli/js/lib.deno.ns.d.ts @@ -63,24 +63,6 @@ declare namespace Deno { * * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts"; * - * Deno.test(function myTestFunction():void { - * assertEquals("hello", "hello"); - * }); - * - * Deno.test(async function myAsyncTestFunction():Promise<void> { - * const decoder = new TextDecoder("utf-8"); - * const data = await Deno.readFile("hello_world.txt"); - * assertEquals(decoder.decode(data), "Hello world") - * }); - **/ - export function test(fn: () => void | Promise<void>): void; - - /** Register a test which will be run when `deno test` is used on the command - * line and the containing module looks like a test module. - * `fn` can be async if required. - * - * import {assert, fail, assertEquals} from "https://deno.land/std/testing/asserts.ts"; - * * Deno.test("My test description", ():void => { * assertEquals("hello", "hello"); * }); diff --git a/cli/js/testing.ts b/cli/js/testing.ts index 93b603419..09acdc23d 100644 --- a/cli/js/testing.ts +++ b/cli/js/testing.ts @@ -93,12 +93,11 @@ export interface TestDefinition { const TEST_REGISTRY: TestDefinition[] = []; export function test(t: TestDefinition): void; -export function test(fn: () => void | Promise<void>): void; export function test(name: string, fn: () => void | Promise<void>): void; // Main test function provided by Deno, as you can see it merely // creates a new object with "name" and "fn" fields. export function test( - t: string | TestDefinition | (() => void | Promise<void>), + t: string | TestDefinition, fn?: () => void | Promise<void> ): void { let testDef: TestDefinition; @@ -116,11 +115,6 @@ export function test( throw new TypeError("The test name can't be empty"); } testDef = { fn: fn as () => void | Promise<void>, name: t, ...defaults }; - } else if (typeof t === "function") { - if (!t.name) { - throw new TypeError("The test function can't be anonymous"); - } - testDef = { fn: t, name: t.name, ...defaults }; } else { if (!t.fn) { throw new TypeError("Missing test function"); diff --git a/cli/js/tests/testing_test.ts b/cli/js/tests/testing_test.ts index 09378ec30..854e7161c 100644 --- a/cli/js/tests/testing_test.ts +++ b/cli/js/tests/testing_test.ts @@ -25,13 +25,3 @@ unitTest(function nameOfTestCaseCantBeEmpty(): void { "The test name can't be empty" ); }); - -unitTest(function testFnCantBeAnonymous(): void { - assertThrows( - () => { - Deno.test(function () {}); - }, - TypeError, - "The test function can't be anonymous" - ); -}); |