diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/mod.rs | 20 | ||||
-rw-r--r-- | cli/tests/integration/test_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/testdata/test/overloads.out | 11 | ||||
-rw-r--r-- | cli/tests/testdata/test/overloads.ts | 6 | ||||
-rw-r--r-- | cli/tests/unit/testing_test.ts | 60 |
5 files changed, 90 insertions, 13 deletions
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs index 21ffc5627..cfb950901 100644 --- a/cli/tests/integration/mod.rs +++ b/cli/tests/integration/mod.rs @@ -1016,29 +1016,29 @@ async fn test_resolve_dns() { #[test] fn typecheck_declarations_ns() { - let status = util::deno_cmd() + let output = util::deno_cmd() .arg("test") .arg("--doc") .arg(util::root_path().join("cli/dts/lib.deno.ns.d.ts")) - .spawn() - .unwrap() - .wait() + .output() .unwrap(); - assert!(status.success()); + println!("stdout: {}", String::from_utf8(output.stdout).unwrap()); + println!("stderr: {}", String::from_utf8(output.stderr).unwrap()); + assert!(output.status.success()); } #[test] fn typecheck_declarations_unstable() { - let status = util::deno_cmd() + let output = util::deno_cmd() .arg("test") .arg("--doc") .arg("--unstable") .arg(util::root_path().join("cli/dts/lib.deno.unstable.d.ts")) - .spawn() - .unwrap() - .wait() + .output() .unwrap(); - assert!(status.success()); + println!("stdout: {}", String::from_utf8(output.stdout).unwrap()); + println!("stderr: {}", String::from_utf8(output.stderr).unwrap()); + assert!(output.status.success()); } #[test] diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index e5d3fd358..3f23efca2 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -19,6 +19,12 @@ fn no_color() { assert!(out.contains("test result: FAILED. 1 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out")); } +itest!(overloads { + args: "test test/overloads.ts", + exit_code: 0, + output: "test/overloads.out", +}); + itest!(meta { args: "test test/meta.ts", exit_code: 0, diff --git a/cli/tests/testdata/test/overloads.out b/cli/tests/testdata/test/overloads.out new file mode 100644 index 000000000..13c088f6c --- /dev/null +++ b/cli/tests/testdata/test/overloads.out @@ -0,0 +1,11 @@ +Check [WILDCARD]/test/overloads.ts +running 6 tests from [WILDCARD]/test/overloads.ts +test test0 ... ok ([WILDCARD]) +test test1 ... ok ([WILDCARD]) +test test2 ... ok ([WILDCARD]) +test test3 ... ok ([WILDCARD]) +test test4 ... ok ([WILDCARD]) +test test5 ... ignored ([WILDCARD]) + +test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out ([WILDCARD]) + diff --git a/cli/tests/testdata/test/overloads.ts b/cli/tests/testdata/test/overloads.ts new file mode 100644 index 000000000..eb7b3dccc --- /dev/null +++ b/cli/tests/testdata/test/overloads.ts @@ -0,0 +1,6 @@ +Deno.test("test0", () => {}); +Deno.test(function test1() {}); +Deno.test({ name: "test2", fn: () => {} }); +Deno.test("test3", { permissions: "none" }, () => {}); +Deno.test({ name: "test4" }, () => {}); +Deno.test({ ignore: true }, function test5() {}); 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() { |