fix(striker-ui): add exclude ID list to input tests

main
Tsu-ba-me 2 years ago
parent 469df1b7c1
commit b0731a9c18
  1. 34
      striker-ui/lib/test_input/testInput.ts
  2. 9
      striker-ui/types/TestInputFunction.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<InputTestInputs> =
inputs ??
Object.keys(tests).reduce<
Exclude<TestInputFunctionOptions['inputs'], undefined>
>((reduceContainer, id: string) => {
reduceContainer[id] = {};
return reduceContainer;
Object.keys(tests).reduce<InputTestInputs>((previous, id: string) => {
previous[id] = {};
return previous;
}, {});
let allResult = true;
let setBatchCallback: (
batch?: Partial<
Exclude<TestInputFunctionOptions['tests'], undefined>[string]
>,
) => {
cbFinishBatch: Exclude<
TestInputFunctionOptions['tests'],
undefined
>[string]['onFinishBatch'];
let setBatchCallback: (batch?: Partial<InputTestBatches[string]>) => {
cbFinishBatch: InputTestBatches[string]['onFinishBatch'];
} = () => ({ cbFinishBatch: undefined });
let setSingleCallback: (test?: Partial<InputTest>) => {
cbFailure: InputTest['onFailure'];
@ -46,6 +38,14 @@ const testInput: TestInputFunction = ({
});
}
testsToRun = excludeTestIds.reduce<InputTestInputs>(
(previous, id: string) => {
delete previous[id];
return previous;
},
{ ...testsToRun },
);
Object.keys(testsToRun).every((id: string) => {
const {
defaults: {

@ -21,6 +21,10 @@ export type InputTest = {
test: (args: MinimalInputTestArgs) => boolean;
};
export type InputTestInputs = {
[id: string]: Partial<InputTestArgs>;
};
export type InputTestBatches = {
[id: string]: {
defaults?: InputTestArgs & {
@ -33,9 +37,8 @@ export type InputTestBatches = {
};
export type TestInputFunctionOptions = {
inputs?: {
[id: string]: Partial<InputTestArgs>;
};
excludeTestIds?: string[];
inputs?: InputTestInputs;
isContinueOnFailure?: boolean;
isIgnoreOnCallbacks?: boolean;
tests?: InputTestBatches;

Loading…
Cancel
Save