Przeglądaj źródła

chore: code clean

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 4 miesięcy temu
rodzic
commit
b34fb2b41a

+ 0 - 51
client/src/hooks/__test__/Form.spec.tsx

@@ -1,51 +0,0 @@
-import { renderHook, act } from '@testing-library/react-hooks';
-import { IForm, useFormValidation } from '../Form';
-
-const mockForm: IForm[] = [
-  {
-    key: 'username',
-    value: '',
-    needCheck: true,
-  },
-  {
-    key: 'nickname',
-    value: '',
-    needCheck: false,
-  },
-];
-
-test('test useFormValidation hook', () => {
-  const { result } = renderHook(() => useFormValidation(mockForm));
-  const { checkFormValid, checkIsValid, validation } = result.current;
-
-  expect(checkFormValid(mockForm)).toBeFalsy();
-  expect(Object.keys(validation)).toEqual(['username']);
-
-  act(() => {
-    const { result } = checkIsValid({
-      value: '',
-      key: 'username',
-      rules: [{ rule: 'require', errorText: 'name is required' }],
-    });
-
-    expect(result).toBeTruthy();
-  });
-
-  act(() => {
-    const { result } = checkIsValid({
-      value: '11111',
-      key: 'email',
-      rules: [{ rule: 'email', errorText: 'email is invalid' }],
-    });
-    expect(result).toBeTruthy();
-  });
-
-  act(() => {
-    const { result } = checkIsValid({
-      value: '12345678aQ',
-      key: 'password',
-      rules: [{ rule: 'password', errorText: 'password is invalid' }],
-    });
-    expect(result).toBeTruthy();
-  });
-});

+ 1 - 0
client/src/pages/dialogs/CreateCollectionDialog.tsx

@@ -370,6 +370,7 @@ const CreateCollectionDialog: FC<CollectionCreateProps> = ({ onCreate }) => {
       handleClose={() => {
         handleCloseDialog();
       }}
+      leftActions={<>Import from JSON</>}
       confirmLabel={btnTrans('create')}
       handleConfirm={handleCreateCollection}
       confirmDisabled={disabled || !fieldsValidation}

+ 0 - 17
client/src/utils/__test__/Form.spec.ts

@@ -1,17 +0,0 @@
-import { formatForm } from '../Form';
-
-describe('Test form utils', () => {
-  test('test formatForm function', () => {
-    const mockUserInfo = {
-      name: 'user1',
-      age: 20,
-      isMale: true,
-    };
-
-    const form = formatForm(mockUserInfo);
-    const nameInfo = form.find(item => item.key === 'name');
-    expect(form.length).toBe(3);
-    expect(nameInfo?.value).toBe('user1');
-    expect(nameInfo?.needCheck).toBeTruthy();
-  });
-});

+ 0 - 13
client/src/utils/__test__/Format.spec.ts

@@ -1,13 +0,0 @@
-import { parseByte } from '../Format';
-import { BYTE_UNITS } from '@/consts';
-describe('Test Fromat utils', () => {
-  it('Test parse byte', () => {
-    expect(parseByte('10m')).toEqual(10 * BYTE_UNITS.m);
-    expect(parseByte('10mb')).toEqual(10 * BYTE_UNITS.m);
-    expect(parseByte('10g')).toEqual(10 * BYTE_UNITS.g);
-    expect(parseByte('10gb')).toEqual(10 * BYTE_UNITS.g);
-    expect(parseByte('10k')).toEqual(10 * BYTE_UNITS.k);
-    expect(parseByte('10kb')).toEqual(10 * BYTE_UNITS.k);
-    expect(parseByte('10b')).toEqual(10 * BYTE_UNITS.b);
-  });
-});

+ 0 - 53
client/src/utils/__test__/Validation.spec.ts

@@ -1,53 +0,0 @@
-import {
-  checkEmptyValid,
-  checkEmail,
-  checkPasswordStrength,
-  checkRange,
-  checkClusterName,
-  checkIpOrCIDR,
-  getCheckResult,
-} from '../Validation';
-
-describe('Test validation utils', () => {
-  test('test checkEmptyValid function', () => {
-    expect(checkEmptyValid('')).toBeFalsy();
-    expect(checkEmptyValid('test')).toBeTruthy();
-  });
-
-  test('test checkEmail function', () => {
-    expect(checkEmail('test email')).toBeFalsy();
-    expect(checkEmail('test@qq.com')).toBeTruthy();
-  });
-
-  test('test checkPasswordStrength function', () => {
-    expect(checkPasswordStrength('12345')).toBeFalsy();
-    expect(checkPasswordStrength('12345aa++')).toBeFalsy();
-    expect(checkPasswordStrength('123asadWDWD++')).toBeTruthy();
-  });
-
-  test('test checkRange function', () => {
-    expect(checkRange({ value: 'asdffd', min: 2, max: 5 })).toBeFalsy();
-    expect(checkRange({ value: 'asdffd', min: 2, max: 6 })).toBeTruthy();
-  });
-
-  test('test checkClusterName function', () => {
-    expect(checkClusterName('!!!')).toBeFalsy();
-    expect(checkClusterName('cluster-name')).toBeTruthy();
-  });
-
-  test('test checkIpOrCIDR function', () => {
-    expect(checkIpOrCIDR('172.11.111.11')).toBeTruthy();
-    expect(checkIpOrCIDR('11111.1.1.1')).toBeFalsy();
-  });
-
-  test('test getCheckResult function', () => {
-    expect(getCheckResult({ value: '', rule: 'require' })).toBeFalsy();
-    expect(
-      getCheckResult({
-        value: '12345',
-        extraParam: { min: 8 },
-        rule: 'range',
-      })
-    ).toBeFalsy();
-  });
-});