summaryrefslogtreecommitdiff
path: root/cli/tests/unit/test_util.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-11-23 17:45:18 +0100
committerGitHub <noreply@github.com>2021-11-23 17:45:18 +0100
commitbedb2adfb065c1b0d3bcb773fbeff91230402b6b (patch)
treeb4d90c36f2409f7f9b6247b74e9c111a38befcdf /cli/tests/unit/test_util.ts
parent51e3db956a5927229e3f46f4eaaf317e935f8f17 (diff)
refactor: remove "unitTest" wrapper from cli/tests/unit (#12750)
Diffstat (limited to 'cli/tests/unit/test_util.ts')
-rw-r--r--cli/tests/unit/test_util.ts66
1 files changed, 0 insertions, 66 deletions
diff --git a/cli/tests/unit/test_util.ts b/cli/tests/unit/test_util.ts
index 65d23af65..80af8fdfc 100644
--- a/cli/tests/unit/test_util.ts
+++ b/cli/tests/unit/test_util.ts
@@ -23,72 +23,6 @@ export { delay } from "../../../test_util/std/async/delay.ts";
export { readLines } from "../../../test_util/std/io/bufio.ts";
export { parse as parseArgs } from "../../../test_util/std/flags/mod.ts";
-interface UnitTestPermissions {
- env?: "inherit" | boolean | string[];
- hrtime?: "inherit" | boolean;
- net?: "inherit" | boolean | string[];
- ffi?: "inherit" | boolean;
- read?: "inherit" | boolean | Array<string | URL>;
- run?: "inherit" | boolean | Array<string | URL>;
- write?: "inherit" | boolean | Array<string | URL>;
-}
-
-interface UnitTestOptions {
- ignore?: boolean;
- only?: boolean;
- permissions?: UnitTestPermissions;
-}
-
-type TestFunction = (tester: Deno.TestContext) => void | Promise<void>;
-
-export function unitTest(fn: TestFunction): void;
-export function unitTest(options: UnitTestOptions, fn: TestFunction): void;
-export function unitTest(
- optionsOrFn: UnitTestOptions | TestFunction,
- maybeFn?: TestFunction,
-): void {
- assert(optionsOrFn, "At least one argument is required");
-
- let options: UnitTestOptions;
- let name: string;
- let fn: TestFunction;
-
- if (typeof optionsOrFn === "function") {
- options = {};
- fn = optionsOrFn;
- name = fn.name;
- assert(name, "Missing test function name");
- } else {
- options = optionsOrFn;
- assert(maybeFn, "Missing test function definition");
- assert(
- typeof maybeFn === "function",
- "Second argument should be test function definition",
- );
- fn = maybeFn;
- name = fn.name;
- assert(name, "Missing test function name");
- }
-
- const testDefinition: Deno.TestDefinition = {
- name,
- fn,
- ignore: !!options.ignore,
- only: !!options.only,
- permissions: Object.assign({
- read: false,
- write: false,
- net: false,
- env: false,
- run: false,
- ffi: false,
- hrtime: false,
- }, options.permissions),
- };
-
- Deno.test(testDefinition);
-}
-
export function pathToAbsoluteFileUrl(path: string): URL {
path = resolve(path);