From b0731a9c1814514097dc86ce73d69150c228aa00 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Fri, 12 Aug 2022 19:30:18 -0400 Subject: [PATCH] fix(striker-ui): add exclude ID list to input tests --- striker-ui/lib/test_input/testInput.ts | 34 +++++++++++++------------- striker-ui/types/TestInputFunction.ts | 9 ++++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/striker-ui/lib/test_input/testInput.ts b/striker-ui/lib/test_input/testInput.ts index b2716134..799d1ffc 100644 --- a/striker-ui/lib/test_input/testInput.ts +++ b/striker-ui/lib/test_input/testInput.ts @@ -1,35 +1,27 @@ import { InputTest, + InputTestBatches, + InputTestInputs, TestInputFunction, - TestInputFunctionOptions, } from '../../types/TestInputFunction'; const testInput: TestInputFunction = ({ + excludeTestIds = [], inputs, isContinueOnFailure, isIgnoreOnCallbacks, tests = {}, } = {}): boolean => { - const testsToRun = + let testsToRun: Readonly = inputs ?? - Object.keys(tests).reduce< - Exclude - >((reduceContainer, id: string) => { - reduceContainer[id] = {}; - return reduceContainer; + Object.keys(tests).reduce((previous, id: string) => { + previous[id] = {}; + return previous; }, {}); - let allResult = true; - let setBatchCallback: ( - batch?: Partial< - Exclude[string] - >, - ) => { - cbFinishBatch: Exclude< - TestInputFunctionOptions['tests'], - undefined - >[string]['onFinishBatch']; + let setBatchCallback: (batch?: Partial) => { + cbFinishBatch: InputTestBatches[string]['onFinishBatch']; } = () => ({ cbFinishBatch: undefined }); let setSingleCallback: (test?: Partial) => { cbFailure: InputTest['onFailure']; @@ -46,6 +38,14 @@ const testInput: TestInputFunction = ({ }); } + testsToRun = excludeTestIds.reduce( + (previous, id: string) => { + delete previous[id]; + return previous; + }, + { ...testsToRun }, + ); + Object.keys(testsToRun).every((id: string) => { const { defaults: { diff --git a/striker-ui/types/TestInputFunction.ts b/striker-ui/types/TestInputFunction.ts index 24629d3b..ea72792c 100644 --- a/striker-ui/types/TestInputFunction.ts +++ b/striker-ui/types/TestInputFunction.ts @@ -21,6 +21,10 @@ export type InputTest = { test: (args: MinimalInputTestArgs) => boolean; }; +export type InputTestInputs = { + [id: string]: Partial; +}; + export type InputTestBatches = { [id: string]: { defaults?: InputTestArgs & { @@ -33,9 +37,8 @@ export type InputTestBatches = { }; export type TestInputFunctionOptions = { - inputs?: { - [id: string]: Partial; - }; + excludeTestIds?: string[]; + inputs?: InputTestInputs; isContinueOnFailure?: boolean; isIgnoreOnCallbacks?: boolean; tests?: InputTestBatches;