refactor(striker-ui): don't export test input types

main
Tsu-ba-me 2 years ago
parent 2d6e309534
commit 4488477f3b
  1. 4
      striker-ui/components/GeneralInitForm.tsx
  2. 4
      striker-ui/components/NetworkInitForm.tsx
  3. 4
      striker-ui/components/ProvisionServerDialog.tsx
  4. 5
      striker-ui/lib/test_input/createTestInputFunction.ts
  5. 10
      striker-ui/lib/test_input/testInput.ts
  6. 2
      striker-ui/lib/test_input/testLength.ts
  7. 2
      striker-ui/lib/test_input/testMax.ts
  8. 2
      striker-ui/lib/test_input/testNotBlank.ts
  9. 2
      striker-ui/lib/test_input/testRange.ts
  10. 30
      striker-ui/types/TestInputFunction.d.ts

@ -23,10 +23,6 @@ import OutlinedInputWithLabel, {
import pad from '../lib/pad';
import SuggestButton from './SuggestButton';
import { createTestInputFunction, testNotBlank } from '../lib/test_input';
import {
InputTestBatches,
TestInputFunctionOptions,
} from '../types/TestInputFunction';
import { BodyText, InlineMonoText } from './Text';
type GeneralInitFormValues = {

@ -51,10 +51,6 @@ import SelectWithLabel from './SelectWithLabel';
import Spinner from './Spinner';
import sumstring from '../lib/sumstring';
import { createTestInputFunction, testNotBlank } from '../lib/test_input';
import {
InputTestBatches,
TestInputFunctionOptions,
} from '../types/TestInputFunction';
import { BodyText, MonoText, SmallText } from './Text';
type NetworkInput = {

@ -32,10 +32,6 @@ import {
testNotBlank,
testRange,
} from '../lib/test_input';
import {
InputTestBatches,
TestInputFunction,
} from '../types/TestInputFunction';
import { BodyText, HeaderText, InlineMonoText } from './Text';
type InputMessage = Partial<Pick<MessageBoxProps, 'type' | 'text'>>;

@ -1,9 +1,4 @@
import testInput from './testInput';
import {
InputTestBatches,
TestInputFunction,
TestInputFunctionOptions,
} from '../../types/TestInputFunction';
const createTestInputFunction =
(

@ -1,13 +1,3 @@
import {
InputTest,
InputTestInputs,
CallbackAppendArgs,
TestInputFunction,
InputTestBatchFinishCallback,
InputTestFailureCallback,
InputTestSuccessCallback,
} from '../../types/TestInputFunction';
type TestCallbacks = Pick<InputTest, 'onFailure' | 'onSuccess'>;
const cbEmptySetter = () => ({});

@ -1,5 +1,3 @@
import { MinimalInputTestArgs } from '../../types/TestInputFunction';
const testLength: (
args: Pick<MinimalInputTestArgs, 'value'> &
Partial<Pick<MinimalInputTestArgs, 'max' | 'min'>>,

@ -1,5 +1,3 @@
import { MinimalInputTestArgs } from '../../types/TestInputFunction';
const testMax: (args: MinimalInputTestArgs) => boolean = ({ max, min }) =>
max >= min;

@ -1,5 +1,3 @@
import { MinimalInputTestArgs } from '../../types/TestInputFunction';
const testNotBlank: (args: MinimalInputTestArgs) => boolean = ({ value }) =>
value ? String(value).length > 0 : false;

@ -1,5 +1,3 @@
import { MinimalInputTestArgs } from '../../types/TestInputFunction';
const testRange: (args: MinimalInputTestArgs) => boolean = ({
max,
min,

@ -1,12 +1,6 @@
export type InputTestValue =
| bigint
| boolean
| number
| null
| string
| undefined;
type InputTestValue = bigint | boolean | number | null | string | undefined;
export type InputTestArgs = {
type InputTestArgs = {
compare?: InputTestValue[];
displayMax?: string;
displayMin?: string;
@ -18,7 +12,7 @@ export type InputTestArgs = {
value?: InputTestValue;
};
export type MinimalInputTestArgs = Required<
type MinimalInputTestArgs = Required<
Omit<
InputTestArgs,
| 'displayMax'
@ -29,31 +23,31 @@ export type MinimalInputTestArgs = Required<
>
>;
export type CallbackAppendArgs = {
type CallbackAppendArgs = {
append: {
[arg: string]: InputTestValue;
};
};
export type InputTestFailureCallback = (
type InputTestFailureCallback = (
args: InputTestArgs & CallbackAppendArgs,
) => void;
export type InputTestSuccessCallback = (args: CallbackAppendArgs) => void;
type InputTestSuccessCallback = (args: CallbackAppendArgs) => void;
export type InputTest = {
type InputTest = {
onFailure?: InputTestFailureCallback;
onSuccess?: InputTestSuccessCallback;
test: (args: MinimalInputTestArgs & CallbackAppendArgs) => boolean;
};
export type InputTestInputs = {
type InputTestInputs = {
[id: string]: Partial<InputTestArgs>;
};
export type InputTestBatchFinishCallback = () => void;
type InputTestBatchFinishCallback = () => void;
export type InputTestBatches = {
type InputTestBatches = {
[id: string]: {
defaults?: InputTestArgs & {
onSuccess?: InputTestSuccessCallback;
@ -64,7 +58,7 @@ export type InputTestBatches = {
};
};
export type TestInputFunctionOptions = {
type TestInputFunctionOptions = {
excludeTestIds?: string[];
excludeTestIdsRe?: RegExp;
inputs?: InputTestInputs;
@ -74,4 +68,4 @@ export type TestInputFunctionOptions = {
tests?: InputTestBatches;
};
export type TestInputFunction = (options?: TestInputFunctionOptions) => boolean;
type TestInputFunction = (options?: TestInputFunctionOptions) => boolean;
Loading…
Cancel
Save