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 pad from '../lib/pad';
import SuggestButton from './SuggestButton'; import SuggestButton from './SuggestButton';
import { createTestInputFunction, testNotBlank } from '../lib/test_input'; import { createTestInputFunction, testNotBlank } from '../lib/test_input';
import {
InputTestBatches,
TestInputFunctionOptions,
} from '../types/TestInputFunction';
import { BodyText, InlineMonoText } from './Text'; import { BodyText, InlineMonoText } from './Text';
type GeneralInitFormValues = { type GeneralInitFormValues = {

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

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

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

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

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

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

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

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

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