diff options
Diffstat (limited to 'cli/tests/unit/testing_test.ts')
-rw-r--r-- | cli/tests/unit/testing_test.ts | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/cli/tests/unit/testing_test.ts b/cli/tests/unit/testing_test.ts index 144246002..d4d25d12f 100644 --- a/cli/tests/unit/testing_test.ts +++ b/cli/tests/unit/testing_test.ts @@ -1,9 +1,63 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. import { assertRejects, assertThrows, unitTest } from "./test_util.ts"; -unitTest(function testFnOverloading() { - // just verifying that you can use this test definition syntax - Deno.test("test fn overloading", () => {}); +unitTest(function testWrongOverloads() { + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test("some name", { fn: () => {} }, () => {}); + }, + TypeError, + "Unexpected 'fn' field in options, test function is already provided as the third argument.", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test("some name", { name: "some name2" }, () => {}); + }, + TypeError, + "Unexpected 'name' field in options, test name is already provided as the first argument.", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test(() => {}); + }, + TypeError, + "The test function must have a name", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test(function foo() {}, {}); + }, + TypeError, + "Unexpected second argument to Deno.test()", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test({ fn: () => {} }, function foo() {}); + }, + TypeError, + "Unexpected 'fn' field in options, test function is already provided as the second argument.", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test({}); + }, + TypeError, + "Expected 'fn' field in the first argument to be a test function.", + ); + assertThrows( + () => { + // @ts-ignore Testing invalid overloads + Deno.test({ fn: "boo!" }); + }, + TypeError, + "Expected 'fn' field in the first argument to be a test function.", + ); }); unitTest(function nameOfTestCaseCantBeEmpty() { |