summaryrefslogtreecommitdiff
path: root/cli/tests/unit/testing_test.ts
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-10-11 09:45:02 -0400
committerGitHub <noreply@github.com>2021-10-11 09:45:02 -0400
commit426ebf854a82c63cdaa2413fbd1b005025dba95b (patch)
tree316a426e280db29745444e7606952c8c235c846a /cli/tests/unit/testing_test.ts
parent668b400ff2fa5634f575e54f40ab1f0b78fcdf16 (diff)
feat(unstable/test): imperative test steps API (#12190)
Diffstat (limited to 'cli/tests/unit/testing_test.ts')
-rw-r--r--cli/tests/unit/testing_test.ts40
1 files changed, 39 insertions, 1 deletions
diff --git a/cli/tests/unit/testing_test.ts b/cli/tests/unit/testing_test.ts
index 89b3cc31f..144246002 100644
--- a/cli/tests/unit/testing_test.ts
+++ b/cli/tests/unit/testing_test.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-import { assertThrows, unitTest } from "./test_util.ts";
+import { assertRejects, assertThrows, unitTest } from "./test_util.ts";
unitTest(function testFnOverloading() {
// just verifying that you can use this test definition syntax
@@ -25,3 +25,41 @@ unitTest(function nameOfTestCaseCantBeEmpty() {
"The test name can't be empty",
);
});
+
+unitTest(function invalidStepArguments(t) {
+ assertRejects(
+ async () => {
+ // deno-lint-ignore no-explicit-any
+ await (t as any).step("test");
+ },
+ TypeError,
+ "Expected function for second argument.",
+ );
+
+ assertRejects(
+ async () => {
+ // deno-lint-ignore no-explicit-any
+ await (t as any).step("test", "not a function");
+ },
+ TypeError,
+ "Expected function for second argument.",
+ );
+
+ assertRejects(
+ async () => {
+ // deno-lint-ignore no-explicit-any
+ await (t as any).step();
+ },
+ TypeError,
+ "Expected a test definition or name and function.",
+ );
+
+ assertRejects(
+ async () => {
+ // deno-lint-ignore no-explicit-any
+ await (t as any).step(() => {});
+ },
+ TypeError,
+ "Expected a test definition or name and function.",
+ );
+});