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 { import {
InputTest, InputTest,
InputTestBatches,
InputTestInputs,
TestInputFunction, TestInputFunction,
TestInputFunctionOptions,
} from '../../types/TestInputFunction'; } from '../../types/TestInputFunction';
const testInput: TestInputFunction = ({ const testInput: TestInputFunction = ({
excludeTestIds = [],
inputs, inputs,
isContinueOnFailure, isContinueOnFailure,
isIgnoreOnCallbacks, isIgnoreOnCallbacks,
tests = {}, tests = {},
} = {}): boolean => { } = {}): boolean => {
const testsToRun = let testsToRun: Readonly<InputTestInputs> =
inputs ?? inputs ??
Object.keys(tests).reduce< Object.keys(tests).reduce<InputTestInputs>((previous, id: string) => {
Exclude<TestInputFunctionOptions['inputs'], undefined> previous[id] = {};
>((reduceContainer, id: string) => { return previous;
reduceContainer[id] = {};
return reduceContainer;
}, {}); }, {});
let allResult = true; let allResult = true;
let setBatchCallback: ( let setBatchCallback: (batch?: Partial<InputTestBatches[string]>) => {
batch?: Partial< cbFinishBatch: InputTestBatches[string]['onFinishBatch'];
Exclude<TestInputFunctionOptions['tests'], undefined>[string]
>,
) => {
cbFinishBatch: Exclude<
TestInputFunctionOptions['tests'],
undefined
>[string]['onFinishBatch'];
} = () => ({ cbFinishBatch: undefined }); } = () => ({ cbFinishBatch: undefined });
let setSingleCallback: (test?: Partial<InputTest>) => { let setSingleCallback: (test?: Partial<InputTest>) => {
cbFailure: InputTest['onFailure']; 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) => { Object.keys(testsToRun).every((id: string) => {
const { const {
defaults: { defaults: {

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

Loading…
Cancel
Save