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;