diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-04-23 13:40:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 14:40:16 +0200 |
commit | 65bba2b87e4bc2e1ba0e673caf43974a432acc25 (patch) | |
tree | e26273ddddf8dd22e5fbd7318009b673277ba9d5 /cli/js/testing.ts | |
parent | d8711155ca20fb2907beed304557d0815ac56452 (diff) |
refactor(cli/js/testing): Rename disableOpSanitizer to sanitizeOps (#4854)
* rename disableOpSanitizer to sanitizeOps
* rename disableResourceSanitizer to sanitizeResources
Diffstat (limited to 'cli/js/testing.ts')
-rw-r--r-- | cli/js/testing.ts | 19 |
1 files changed, 12 insertions, 7 deletions
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); } |