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

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

Loading…
Cancel
Save