0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

refactor(cli/js/testing): Rename disableOpSanitizer to sanitizeOps (#4854)

* rename disableOpSanitizer to sanitizeOps
* rename disableResourceSanitizer to sanitizeResources
This commit is contained in:
Nayeem Rahman 2020-04-23 13:40:16 +01:00 committed by GitHub
parent d8711155ca
commit 65bba2b87e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 9 deletions

View file

@ -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

View file

@ -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);
}