summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/lib.deno.ns.d.ts4
-rw-r--r--cli/js/testing.ts19
2 files changed, 14 insertions, 9 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index eb61f2331..9980790b3 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -16,8 +16,8 @@ declare namespace Deno {
fn: () => void | Promise<void>;
name: string;
ignore?: boolean;
- disableOpSanitizer?: boolean;
- disableResourceSanitizer?: boolean;
+ sanitizeOps?: boolean;
+ sanitizeResources?: boolean;
}
/** Register a test which will be run when `deno test` is used on the command
diff --git a/cli/js/testing.ts b/cli/js/testing.ts
index 542e1d065..6c56a2f71 100644
--- a/cli/js/testing.ts
+++ b/cli/js/testing.ts
@@ -80,8 +80,8 @@ export interface TestDefinition {
fn: () => void | Promise<void>;
name: string;
ignore?: boolean;
- disableOpSanitizer?: boolean;
- disableResourceSanitizer?: boolean;
+ sanitizeOps?: boolean;
+ sanitizeResources?: boolean;
}
const TEST_REGISTRY: TestDefinition[] = [];
@@ -96,6 +96,11 @@ export function test(
fn?: () => void | Promise<void>
): void {
let testDef: TestDefinition;
+ const defaults = {
+ ignore: false,
+ sanitizeOps: true,
+ sanitizeResources: true,
+ };
if (typeof t === "string") {
if (!fn || typeof fn != "function") {
@@ -104,12 +109,12 @@ export function test(
if (!t) {
throw new TypeError("The test name can't be empty");
}
- testDef = { fn: fn as () => void | Promise<void>, name: t, ignore: false };
+ testDef = { fn: fn as () => void | Promise<void>, name: t, ...defaults };
} else if (typeof t === "function") {
if (!t.name) {
throw new TypeError("The test function can't be anonymous");
}
- testDef = { fn: t, name: t.name, ignore: false };
+ testDef = { fn: t, name: t.name, ...defaults };
} else {
if (!t.fn) {
throw new TypeError("Missing test function");
@@ -117,14 +122,14 @@ export function test(
if (!t.name) {
throw new TypeError("The test name can't be empty");
}
- testDef = { ...t, ignore: Boolean(t.ignore) };
+ testDef = { ...defaults, ...t };
}
- if (testDef.disableOpSanitizer !== true) {
+ if (testDef.sanitizeOps) {
testDef.fn = assertOps(testDef.fn);
}
- if (testDef.disableResourceSanitizer !== true) {
+ if (testDef.sanitizeResources) {
testDef.fn = assertResources(testDef.fn);
}