fix(striker-ui): add option to run all input tests

main
Tsu-ba-me 2 years ago
parent c87958e7d8
commit 94f6a2d481
  1. 41
      striker-ui/lib/test_input/testInput.ts
  2. 1
      striker-ui/types/TestInputFunction.ts

@ -8,17 +8,13 @@ import {
const testInput: TestInputFunction = ({
excludeTestIds = [],
inputs,
inputs = {},
isContinueOnFailure,
isIgnoreOnCallbacks,
isTestAll = Object.keys(inputs).length === 0,
tests = {},
} = {}): boolean => {
let testsToRun: Readonly<InputTestInputs> =
inputs ??
Object.keys(tests).reduce<InputTestInputs>((previous, id: string) => {
previous[id] = {};
return previous;
}, {});
let testsToRun: InputTestInputs = {};
let allResult = true;
let setBatchCallback: (batch?: Partial<InputTestBatches[string]>) => {
@ -39,13 +35,17 @@ const testInput: TestInputFunction = ({
});
}
testsToRun = excludeTestIds.reduce<InputTestInputs>(
(previous, id: string) => {
delete previous[id];
return previous;
},
{ ...testsToRun },
);
if (isTestAll) {
Object.keys(tests).forEach((id: string) => {
testsToRun[id] = {};
});
}
testsToRun = { ...testsToRun, ...inputs };
excludeTestIds.forEach((id: string) => {
delete testsToRun[id];
});
Object.keys(testsToRun).every((id: string) => {
const {
@ -120,11 +120,14 @@ const testInput: TestInputFunction = ({
const requiredTestsResult = requiredTests.every(runTest);
// console.log(
// `[${requiredTestsResult ? 'PASS' : 'FAILED'}]id=${id},getValue=${
// getValue !== undefined
// },value=${value}`,
// );
// Log for debug testing only.
// (() => {
// console.log(
// `[${requiredTestsResult ? 'PASS' : 'FAILED'}]id=${id},getValue=${
// getValue !== undefined
// },value=${value}`,
// );
// })();
cbFinishBatch?.call(null);

@ -49,6 +49,7 @@ export type TestInputFunctionOptions = {
inputs?: InputTestInputs;
isContinueOnFailure?: boolean;
isIgnoreOnCallbacks?: boolean;
isTestAll?: boolean;
tests?: InputTestBatches;
};

Loading…
Cancel
Save