2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2021-10-11 09:45:02 -04:00
|
|
|
import { assertRejects, assertThrows, unitTest } from "./test_util.ts";
|
2020-03-05 05:52:18 -05:00
|
|
|
|
2021-08-05 07:08:58 -04:00
|
|
|
unitTest(function testFnOverloading() {
|
2020-03-05 05:52:18 -05:00
|
|
|
// just verifying that you can use this test definition syntax
|
2021-08-05 07:08:58 -04:00
|
|
|
Deno.test("test fn overloading", () => {});
|
2020-03-05 05:52:18 -05:00
|
|
|
});
|
|
|
|
|
2021-08-05 07:08:58 -04:00
|
|
|
unitTest(function nameOfTestCaseCantBeEmpty() {
|
2020-03-05 05:52:18 -05:00
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
Deno.test("", () => {});
|
|
|
|
},
|
2020-03-15 05:34:24 -04:00
|
|
|
TypeError,
|
2020-07-14 15:24:17 -04:00
|
|
|
"The test name can't be empty",
|
2020-03-05 05:52:18 -05:00
|
|
|
);
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
Deno.test({
|
|
|
|
name: "",
|
2020-03-28 13:03:49 -04:00
|
|
|
fn: () => {},
|
2020-03-05 05:52:18 -05:00
|
|
|
});
|
|
|
|
},
|
2020-03-15 05:34:24 -04:00
|
|
|
TypeError,
|
2020-07-14 15:24:17 -04:00
|
|
|
"The test name can't be empty",
|
2020-03-05 05:52:18 -05:00
|
|
|
);
|
|
|
|
});
|
2021-10-11 09:45:02 -04:00
|
|
|
|
|
|
|
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.",
|
|
|
|
);
|
|
|
|
});
|