2022-11-15 20:38:59 +00:00
|
|
|
type InputTestValue = bigint | boolean | number | null | string | undefined;
|
2022-08-12 20:14:01 +00:00
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type InputTestArgs = {
|
2022-08-16 00:17:25 +00:00
|
|
|
compare?: InputTestValue[];
|
2022-05-06 17:14:05 +00:00
|
|
|
displayMax?: string;
|
|
|
|
displayMin?: string;
|
2022-08-16 00:17:25 +00:00
|
|
|
getCompare?: () => InputTestValue[];
|
2022-08-12 20:14:01 +00:00
|
|
|
getValue?: () => InputTestValue;
|
2022-08-19 02:49:11 +00:00
|
|
|
isIgnoreOnCallbacks?: boolean;
|
2022-05-13 18:43:21 +00:00
|
|
|
max?: bigint | number;
|
|
|
|
min?: bigint | number;
|
2022-08-12 20:14:01 +00:00
|
|
|
value?: InputTestValue;
|
2022-05-05 18:55:01 +00:00
|
|
|
};
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type MinimalInputTestArgs = Required<
|
2022-08-19 02:49:11 +00:00
|
|
|
Omit<
|
|
|
|
InputTestArgs,
|
|
|
|
| 'displayMax'
|
|
|
|
| 'displayMin'
|
|
|
|
| 'getCompare'
|
|
|
|
| 'getValue'
|
|
|
|
| 'isIgnoreOnCallbacks'
|
|
|
|
>
|
2022-05-13 18:43:21 +00:00
|
|
|
>;
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type CallbackAppendArgs = {
|
2022-08-16 00:17:25 +00:00
|
|
|
append: {
|
|
|
|
[arg: string]: InputTestValue;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type InputTestFailureCallback = (
|
2022-08-19 02:49:11 +00:00
|
|
|
args: InputTestArgs & CallbackAppendArgs,
|
|
|
|
) => void;
|
|
|
|
|
2022-11-16 04:15:53 +00:00
|
|
|
type InputTestFailureAppendCallback = (
|
|
|
|
message: import('react').ReactNode,
|
|
|
|
...args: Parameters<InputTestFailureCallback>
|
|
|
|
) => void;
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type InputTestSuccessCallback = (args: CallbackAppendArgs) => void;
|
2022-08-16 00:17:25 +00:00
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type InputTest = {
|
2022-08-19 02:49:11 +00:00
|
|
|
onFailure?: InputTestFailureCallback;
|
2022-08-16 00:17:25 +00:00
|
|
|
onSuccess?: InputTestSuccessCallback;
|
|
|
|
test: (args: MinimalInputTestArgs & CallbackAppendArgs) => boolean;
|
2022-05-05 18:55:01 +00:00
|
|
|
};
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type InputTestInputs = {
|
2022-08-12 23:30:18 +00:00
|
|
|
[id: string]: Partial<InputTestArgs>;
|
|
|
|
};
|
|
|
|
|
2022-11-25 04:56:46 +00:00
|
|
|
type InputTestBatchFinishCallback = (result: boolean, id: string) => void;
|
2022-08-19 02:49:11 +00:00
|
|
|
|
2022-11-16 04:15:53 +00:00
|
|
|
type InputTestBatch = {
|
|
|
|
defaults?: InputTestArgs & {
|
|
|
|
onSuccess?: InputTestSuccessCallback;
|
2022-05-05 18:55:01 +00:00
|
|
|
};
|
2022-11-25 04:56:46 +00:00
|
|
|
isRequired?: boolean;
|
2022-11-16 04:15:53 +00:00
|
|
|
onFinishBatch?: InputTestBatchFinishCallback;
|
|
|
|
optionalTests?: Array<InputTest>;
|
|
|
|
tests: Array<InputTest>;
|
|
|
|
};
|
|
|
|
|
|
|
|
type BuildInputTestBatchFunction = (
|
|
|
|
inputName: string,
|
|
|
|
onSuccess: InputTestSuccessCallback,
|
2023-03-04 00:28:48 +00:00
|
|
|
options?: InputTestBatch['defaults'] &
|
|
|
|
Pick<InputTestBatch, 'isRequired' | 'onFinishBatch'>,
|
2022-11-16 04:15:53 +00:00
|
|
|
...onFailureAppends: InputTestFailureAppendCallback[]
|
|
|
|
) => InputTestBatch;
|
|
|
|
|
|
|
|
type InputTestBatches = {
|
|
|
|
[id: string]: InputTestBatch;
|
2022-05-05 18:55:01 +00:00
|
|
|
};
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type TestInputFunctionOptions = {
|
2022-08-12 23:30:18 +00:00
|
|
|
excludeTestIds?: string[];
|
2022-08-19 23:33:59 +00:00
|
|
|
excludeTestIdsRe?: RegExp;
|
2022-08-12 23:30:18 +00:00
|
|
|
inputs?: InputTestInputs;
|
2022-05-05 18:55:01 +00:00
|
|
|
isContinueOnFailure?: boolean;
|
|
|
|
isIgnoreOnCallbacks?: boolean;
|
2022-08-17 23:05:13 +00:00
|
|
|
isTestAll?: boolean;
|
2022-05-05 18:55:01 +00:00
|
|
|
tests?: InputTestBatches;
|
|
|
|
};
|
|
|
|
|
2022-11-15 20:38:59 +00:00
|
|
|
type TestInputFunction = (options?: TestInputFunctionOptions) => boolean;
|