diff --git a/.github/labeler.yml b/.github/labeler.yml index f07126c96..e8da31ba5 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,68 +1,104 @@ 'Area: Bridge': - - 'packages/uniforms-bridge-graphql/**/*' - - 'packages/uniforms-bridge-json-schema/**/*' - - 'packages/uniforms-bridge-simple-schema-2/**/*' - - 'packages/uniforms-bridge-simple-schema/**/*' - - 'packages/uniforms-bridge-zod/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-graphql/**/* + - packages/uniforms-bridge-json-schema/**/* + - packages/uniforms-bridge-simple-schema-2/**/* + - packages/uniforms-bridge-simple-schema/**/* + - packages/uniforms-bridge-zod/**/* 'Area: Core': - - 'packages/uniforms/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms/**/* 'Area: Docs': - - 'CODE_OF_CONDUCT.md' - - 'LICENSE' - - 'README.md' - - 'docs/**/*' - - 'reproductions/**/*' - - 'website/**/*' + - changed-files: + - any-glob-to-any-file: + - CODE_OF_CONDUCT.md + - LICENSE + - README.md + - docs/**/* + - reproductions/**/* + - website/**/* 'Area: Infra': - - '.editorconfig' - - '.eslintignore' - - '.eslintrc.json' - - '.github/**/*' - - '.gitignore' - - '.lintstagedrc.js' - - '.prettierignore' - - '.prettierrc.js' - - '.stylelintrc' - - 'jest.config.js' - - 'lerna.json' - - 'package-lock.json' - - 'package.json' - - 'scripts/**/*' - - 'tsconfig.build.json' - - 'tsconfig.global.json' - - 'tsconfig.json' + - changed-files: + - any-glob-to-any-file: + - .editorconfig + - .eslintignore + - .eslintrc.json + - .github/**/* + - .gitignore + - .lintstagedrc.js + - .prettierignore + - .prettierrc.js + - .stylelintrc + - jest.config.js + - lerna.json + - package-lock.json + - package.json + - scripts/**/* + - tsconfig.build.json + - tsconfig.global.json + - tsconfig.json 'Area: Theme': - - 'packages/uniforms-antd/**/*' - - 'packages/uniforms-bootstrap3/**/*' - - 'packages/uniforms-bootstrap4/**/*' - - 'packages/uniforms-bootstrap5/**/*' - - 'packages/uniforms-material/**/*' - - 'packages/uniforms-mui/**/*' - - 'packages/uniforms-semantic/**/*' - - 'packages/uniforms-unstyled/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-antd/**/* + - packages/uniforms-bootstrap3/**/* + - packages/uniforms-bootstrap4/**/* + - packages/uniforms-bootstrap5/**/* + - packages/uniforms-material/**/* + - packages/uniforms-mui/**/* + - packages/uniforms-semantic/**/* + - packages/uniforms-unstyled/**/* 'Bridge: GraphQL': - - 'packages/uniforms-bridge-graphql/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-graphql/**/* 'Bridge: JSON Schema': - - 'packages/uniforms-bridge-json-schema/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-json-schema/**/* 'Bridge: SimpleSchema': - - 'packages/uniforms-bridge-simple-schema/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-simple-schema/**/* 'Bridge: SimpleSchema (v2)': - - 'packages/uniforms-bridge-simple-schema-2/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-simple-schema-2/**/* 'Bridge: Zod': - - 'packages/uniforms-bridge-zod/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bridge-zod/**/* 'Theme: AntD': - - 'packages/uniforms-antd/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-antd/**/* 'Theme: Bootstrap 3': - - 'packages/uniforms-bootstrap3/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bootstrap3/**/* 'Theme: Bootstrap 4': - - 'packages/uniforms-bootstrap4/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bootstrap4/**/* 'Theme: Bootstrap 5': - - 'packages/uniforms-bootstrap5/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-bootstrap5/**/* 'Theme: Material-UI': - - 'packages/uniforms-material/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-material/**/* 'Theme: MUI': - - 'packages/uniforms-mui/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-mui/**/* 'Theme: Semantic UI': - - 'packages/uniforms-semantic/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-semantic/**/* 'Theme: Unstyled': - - 'packages/uniforms-unstyled/**/*' + - changed-files: + - any-glob-to-any-file: + - packages/uniforms-unstyled/**/* diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d5ea7fe2f..0940bf0e4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,9 +13,9 @@ jobs: node-version: [14.x, 16.x, 18.x, 20.x] steps: - name: Checkout - uses: actions/checkout@v3.3.0 + uses: actions/checkout@v4.1.1 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3.6.0 + uses: actions/setup-node@v4.0.2 with: cache: npm node-version: ${{ matrix.node-version }} @@ -30,14 +30,16 @@ jobs: - name: Test run: npm run coverage -- --no-cache --runInBand - name: Report coverage - uses: codecov/codecov-action@v3.1.1 + uses: codecov/codecov-action@v4.3.0 with: fail_ci_if_error: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - name: Build docs run: npm --prefix website run build if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.node-version == '20.x' - name: Deploy docs - uses: peaceiris/actions-gh-pages@v3.9.2 + uses: peaceiris/actions-gh-pages@v4.0.0 with: allow_empty_commit: true cname: uniforms.tools diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 80ef3a236..dcf620738 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update labels - uses: actions/labeler@v4.0.3 + uses: actions/labeler@v5.0.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} sync-labels: true diff --git a/packages/uniforms-antd/__tests__/SelectField.tsx b/packages/uniforms-antd/__tests__/SelectField.tsx index c95de4fb8..51064b090 100644 --- a/packages/uniforms-antd/__tests__/SelectField.tsx +++ b/packages/uniforms-antd/__tests__/SelectField.tsx @@ -1,4 +1,3 @@ -import Radio from 'antd/lib/radio'; import Select from 'antd/lib/select'; import React from 'react'; import { SelectField } from 'uniforms-antd'; @@ -6,187 +5,6 @@ import { SelectField } from 'uniforms-antd'; import createContext from './_createContext'; import mount from './_mount'; -test(' - renders a select', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); -}); - -test(' - renders a select with correct disabled state', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('disabled')).toBe(true); -}); - -test(' - renders a select with correct readOnly state', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - // FIXME: Provide a valid option. - expect(wrapper.find(Select).prop('onChange')!('b', null as any)).toBeFalsy(); - expect(onChange).not.toHaveBeenCalled(); -}); - -test(' - renders a select with correct id (inherited)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('id')).toBeTruthy(); -}); - -test(' - renders a select with correct id (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('id')).toBe('y'); -}); - -test(' - renders a select with correct name', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('name')).toBe('x'); -}); - -test(' - renders a select with correct options', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('children')).toHaveLength(2); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[0].props.value).toBe('a'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[0].props.children).toBe('a'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[1].props.value).toBe('b'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[1].props.children).toBe('b'); -}); - -test(' - renders a select with correct options (transform)', () => { - const element = ( - - ); - const wrapper = mount(element, createContext({ x: { type: String } })); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('children')).toHaveLength(2); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[0].props.value).toBe('a'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[0].props.children).toBe('A'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[1].props.value).toBe('b'); - // @ts-expect-error Check children type. - expect(wrapper.find(Select).prop('children')[1].props.children).toBe('B'); -}); - -test(' - renders a select with correct placeholder (implicit)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('placeholder')).toBe('y'); - expect(wrapper.find(Select).prop('value')).toBe(undefined); -}); - -test(' - renders a select with correct value (default)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('value')).toBe(undefined); -}); - -test(' - renders a select with correct value (model)', () => { - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' } }, - ), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('value')).toBe('b'); -}); - -test(' - renders a select with correct value (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - expect(wrapper.find(Select).prop('value')).toBe('b'); -}); - -test(' - renders a select which correctly reacts on change', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - // FIXME: Provide a valid option. - expect(wrapper.find(Select).prop('onChange')!('b', null as any)).toBeFalsy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - test(' - renders a select which correctly reacts on change (array)', () => { const onChange = jest.fn(); @@ -224,362 +42,3 @@ test(' - renders a select (undefined values)', () => { expect(wrapper.find(Select).prop('value')).not.toContain(undefined); expect(wrapper.find(Select).prop('value')).toContain('a'); }); - -test(' - renders a select which correctly reacts on change (empty)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - // FIXME: Provide a valid option. - expect(wrapper.find(Select).prop('onChange')!('', null as any)).toBeFalsy(); - expect(onChange).toHaveBeenLastCalledWith('x', ''); -}); - -test(' - renders a select which correctly reacts on change (same value)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' }, onChange }, - ), - ); - - expect(wrapper.find(Select)).toHaveLength(1); - // FIXME: Provide a valid option. - expect(wrapper.find(Select).prop('onChange')!('b', null as any)).toBeFalsy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - -test(' - renders a wrapper with unknown props', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Select).prop('data-x')).toBe('x'); - expect(wrapper.find(Select).prop('data-y')).toBe('y'); - expect(wrapper.find(Select).prop('data-z')).toBe('z'); -}); - -test(' - works with special characters', () => { - mount( - , - createContext({ x: { type: String, allowedValues: ['ă', 'ș'] } }), - ); -}); - -test(' - disabled items (options)', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ - x: { type: Array }, - 'x.$': { type: String }, - }), - ); - - // FIXME: The `children` prop is not indexable on its own. - const children: any = wrapper.find(Select).prop('children'); - expect(children).toHaveLength(2); - expect(children[0].props.disabled).toBe(true); - expect(children[1].props.disabled).toBe(false); -}); - -test(' - renders a set of checkboxes', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio)).toHaveLength(2); - expect(wrapper.find(Radio).at(0).prop('value')).toBe('a'); - expect(wrapper.find(Radio).at(1).prop('value')).toBe('b'); -}); - -test(' - renders a set of checkboxes with correct disabled state', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio.Group)).toHaveLength(1); - expect(wrapper.find(Radio.Group).prop('disabled')).toBe(true); -}); - -test(' - renders a set of checkboxes with correct readOnly state', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).not.toHaveBeenCalled(); -}); - -test(' - renders a set of checkboxes with correct id (inherited)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio.Group)).toHaveLength(1); - expect(wrapper.find(Radio.Group).prop('id')).toBeTruthy(); -}); - -test(' - renders a set of checkboxes with correct id (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio.Group)).toHaveLength(1); - expect(wrapper.find(Radio.Group).prop('id')).toBe('y'); -}); - -test(' - renders a set of checkboxes with correct name', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio.Group)).toHaveLength(1); - expect(wrapper.find(Radio.Group).prop('name')).toBe('x'); -}); - -test(' - renders a set of checkboxes with correct options', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: String, allowedValues: ['a', 'b'], label: '' }, - }), - ); - - expect(wrapper.find('label')).toHaveLength(2); - expect(wrapper.find('label').at(0).text()).toBe('a'); - expect(wrapper.find('label').at(1).text()).toBe('b'); -}); - -test(' - renders a set of checkboxes with correct options (transform)', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ x: { type: String, label: '' } }), - ); - - expect(wrapper.find('label')).toHaveLength(2); - expect(wrapper.find('label').at(0).text()).toBe('A'); - expect(wrapper.find('label').at(1).text()).toBe('B'); -}); - -test(' - renders a set of checkboxes with correct value (default)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(false); -}); - -test(' - renders a set of checkboxes with correct value (model)', () => { - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' } }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(true); -}); - -test(' - renders a set of checkboxes with correct value (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(true); -}); - -test(' - renders a set of checkboxes which correctly reacts on change', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (array check)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', ['b']); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (array uncheck)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', []); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (same value)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' }, onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'a'); -}); - -test(' - renders a label', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('label')).toHaveLength(3); - expect(wrapper.find('label').at(0).text()).toBe('y'); -}); - -test(' - renders a wrapper with unknown props', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find(Radio.Group).prop('data-x')).toBe('x'); - expect(wrapper.find(Radio.Group).prop('data-y')).toBe('y'); - expect(wrapper.find(Radio.Group).prop('data-z')).toBe('z'); -}); - -test(' - works with special characters', () => { - mount( - , - createContext({ x: { type: String, allowedValues: ['ă', 'ș'] } }), - ); -}); - -test(' - disabled items (checkboxes)', () => { - const allowedValues = ['a', 'b']; - - const element = ( - - ); - const wrapper = mount( - element, - createContext({ - x: { type: Array }, - 'x.$': { type: String, allowedValues }, - }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('disabled')).toBe(true); - expect(wrapper.find('input').at(1).prop('disabled')).toBe(false); -}); diff --git a/packages/uniforms-bootstrap3/__tests__/_createContext.ts b/packages/uniforms-bootstrap3/__tests__/_createContext.ts deleted file mode 100644 index e687bc994..000000000 --- a/packages/uniforms-bootstrap3/__tests__/_createContext.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SimpleSchemaDefinition } from 'simpl-schema'; -import { Context, UnknownObject, randomIds, ChangedMap } from 'uniforms'; - -import createSchema from './_createSchema'; - -const randomId = randomIds(); - -export default function createContext( - schema?: SimpleSchemaDefinition, - context?: Partial>, - model = {} as Model, -): { context: Context } { - return { - context: { - changed: false, - changedMap: {} as ChangedMap, - error: null, - model, - name: [], - onChange() {}, - onSubmit() {}, - randomId, - submitted: false, - submitting: false, - validating: false, - ...context, - schema: createSchema(schema), - state: { - disabled: false, - readOnly: false, - showInlineError: false, - ...context?.state, - }, - // @ts-expect-error We don't have a true ref in tests. - formRef: null, - }, - }; -} diff --git a/packages/uniforms-bootstrap3/__tests__/_createSchema.ts b/packages/uniforms-bootstrap3/__tests__/_createSchema.ts deleted file mode 100644 index 6ac1ef72b..000000000 --- a/packages/uniforms-bootstrap3/__tests__/_createSchema.ts +++ /dev/null @@ -1,6 +0,0 @@ -import SimpleSchema, { SimpleSchemaDefinition } from 'simpl-schema'; -import { SimpleSchema2Bridge } from 'uniforms-bridge-simple-schema-2'; - -export default function createSchema(schema: SimpleSchemaDefinition = {}) { - return new SimpleSchema2Bridge({ schema: new SimpleSchema(schema) }); -} diff --git a/packages/uniforms-bootstrap4/__tests__/_createContext.ts b/packages/uniforms-bootstrap4/__tests__/_createContext.ts deleted file mode 100644 index e687bc994..000000000 --- a/packages/uniforms-bootstrap4/__tests__/_createContext.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SimpleSchemaDefinition } from 'simpl-schema'; -import { Context, UnknownObject, randomIds, ChangedMap } from 'uniforms'; - -import createSchema from './_createSchema'; - -const randomId = randomIds(); - -export default function createContext( - schema?: SimpleSchemaDefinition, - context?: Partial>, - model = {} as Model, -): { context: Context } { - return { - context: { - changed: false, - changedMap: {} as ChangedMap, - error: null, - model, - name: [], - onChange() {}, - onSubmit() {}, - randomId, - submitted: false, - submitting: false, - validating: false, - ...context, - schema: createSchema(schema), - state: { - disabled: false, - readOnly: false, - showInlineError: false, - ...context?.state, - }, - // @ts-expect-error We don't have a true ref in tests. - formRef: null, - }, - }; -} diff --git a/packages/uniforms-bootstrap4/__tests__/_createSchema.ts b/packages/uniforms-bootstrap4/__tests__/_createSchema.ts deleted file mode 100644 index 6ac1ef72b..000000000 --- a/packages/uniforms-bootstrap4/__tests__/_createSchema.ts +++ /dev/null @@ -1,6 +0,0 @@ -import SimpleSchema, { SimpleSchemaDefinition } from 'simpl-schema'; -import { SimpleSchema2Bridge } from 'uniforms-bridge-simple-schema-2'; - -export default function createSchema(schema: SimpleSchemaDefinition = {}) { - return new SimpleSchema2Bridge({ schema: new SimpleSchema(schema) }); -} diff --git a/packages/uniforms-bootstrap5/__tests__/_createContext.ts b/packages/uniforms-bootstrap5/__tests__/_createContext.ts deleted file mode 100644 index e687bc994..000000000 --- a/packages/uniforms-bootstrap5/__tests__/_createContext.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SimpleSchemaDefinition } from 'simpl-schema'; -import { Context, UnknownObject, randomIds, ChangedMap } from 'uniforms'; - -import createSchema from './_createSchema'; - -const randomId = randomIds(); - -export default function createContext( - schema?: SimpleSchemaDefinition, - context?: Partial>, - model = {} as Model, -): { context: Context } { - return { - context: { - changed: false, - changedMap: {} as ChangedMap, - error: null, - model, - name: [], - onChange() {}, - onSubmit() {}, - randomId, - submitted: false, - submitting: false, - validating: false, - ...context, - schema: createSchema(schema), - state: { - disabled: false, - readOnly: false, - showInlineError: false, - ...context?.state, - }, - // @ts-expect-error We don't have a true ref in tests. - formRef: null, - }, - }; -} diff --git a/packages/uniforms-bootstrap5/__tests__/_createSchema.ts b/packages/uniforms-bootstrap5/__tests__/_createSchema.ts deleted file mode 100644 index 6ac1ef72b..000000000 --- a/packages/uniforms-bootstrap5/__tests__/_createSchema.ts +++ /dev/null @@ -1,6 +0,0 @@ -import SimpleSchema, { SimpleSchemaDefinition } from 'simpl-schema'; -import { SimpleSchema2Bridge } from 'uniforms-bridge-simple-schema-2'; - -export default function createSchema(schema: SimpleSchemaDefinition = {}) { - return new SimpleSchema2Bridge({ schema: new SimpleSchema(schema) }); -} diff --git a/packages/uniforms-material/__tests__/NestField.tsx b/packages/uniforms-material/__tests__/NestField.tsx index 0d6d107e5..468c11de2 100644 --- a/packages/uniforms-material/__tests__/NestField.tsx +++ b/packages/uniforms-material/__tests__/NestField.tsx @@ -3,7 +3,7 @@ import FormLabel from '@material-ui/core/FormLabel'; import createMuiTheme from '@material-ui/core/styles/createMuiTheme'; import ThemeProvider from '@material-ui/styles/ThemeProvider/ThemeProvider'; import React from 'react'; -import { AutoField, NestField } from 'uniforms-material'; +import { NestField } from 'uniforms-material'; import { render } from 'uniforms/__suites__'; import createContext from './_createContext'; @@ -68,22 +68,6 @@ describe('@RTL - NestField tests', () => { }); }); -test(' - renders an for each field', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: Object }, - 'x.a': { type: String }, - 'x.b': { type: Number }, - }), - ); - - expect(wrapper.find(AutoField)).toHaveLength(2); - expect(wrapper.find(AutoField).at(0).prop('name')).toBe('a'); - expect(wrapper.find(AutoField).at(1).prop('name')).toBe('b'); -}); - test(' - renders a Subheader', () => { const element = ; const wrapper = mount( diff --git a/packages/uniforms-semantic/__tests__/SelectField.tsx b/packages/uniforms-semantic/__tests__/SelectField.tsx index 0ed954c16..4b4a2bd01 100644 --- a/packages/uniforms-semantic/__tests__/SelectField.tsx +++ b/packages/uniforms-semantic/__tests__/SelectField.tsx @@ -4,266 +4,6 @@ import { SelectField } from 'uniforms-semantic'; import createContext from './_createContext'; import mount from './_mount'; -test(' - renders a select', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); -}); - -test(' - renders a select with correct disabled state', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('disabled')).toBe(true); -}); - -test(' - renders a select with correct readOnly state', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper.find('select').simulate('change', { target: { value: 'b' } }), - ).toBeTruthy(); - expect(onChange).not.toHaveBeenCalled(); -}); - -test(' - renders a select with correct id (inherited)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('id')).toBeTruthy(); -}); - -test(' - renders a select with correct id (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('id')).toBe('y'); -}); - -test(' - renders a select with correct name', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('name')).toBe('x'); -}); - -test(' - renders a select with correct options', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: String, allowedValues: ['a', 'b'], label: '' }, - }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('option')).toHaveLength(3); - [ - ['', ''], - ['a', 'a'], - ['b', 'b'], - ].forEach(([value, text], index) => { - const option = wrapper.find('option').at(index); - expect(option.prop('value')).toBe(value); - expect(option.text()).toBe(text); - }); -}); - -test(' - renders a select with correct options (transform)', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ - x: { type: String, allowedValues: ['a', 'b'], label: '' }, - }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('option')).toHaveLength(3); - [ - ['', ''], - ['a', 'A'], - ['b', 'B'], - ].forEach(([value, text], index) => { - const option = wrapper.find('option').at(index); - expect(option.prop('value')).toBe(value); - expect(option.text()).toBe(text); - }); -}); - -test(' - renders a select with correct placeholder (fallback)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: String, allowedValues: ['a', 'b'], optional: true }, - }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('option')).toHaveLength(3); - [ - ['', 'y'], - ['a', 'a'], - ['b', 'b'], - ].forEach(([value, text], index) => { - const option = wrapper.find('option').at(index); - expect(option.prop('value')).toBe(value); - expect(option.text()).toBe(text); - }); -}); - -test(' - renders a select with correct placeholder (implicit)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('option')).toHaveLength(3); - [ - ['', 'y'], - ['a', 'a'], - ['b', 'b'], - ].forEach(([value, text], index) => { - const option = wrapper.find('option').at(index); - expect(option.prop('value')).toBe(value); - expect(option.text()).toBe(text); - }); -}); - -test(' - renders a select with correct value (default)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toBe(''); -}); - -test(' - renders a select with correct value (model)', () => { - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' } }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toBe('b'); -}); - -test(' - renders a select with correct value (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toBe('b'); -}); - -test(' - renders a select which correctly reacts on change', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper.find('select').simulate('change', { target: { value: 'b' } }), - ).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - -test(' - renders a select which correctly reacts on change (empty)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper.find('select').simulate('change', { target: { value: '' } }), - ).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', undefined); -}); - -test(' - renders a select which correctly reacts on change (same value)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' }, onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper.find('select').simulate('change', { target: { value: 'b' } }), - ).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - test(' - renders a label', () => { const element = ; const wrapper = mount( @@ -278,25 +18,6 @@ test(' - renders a label', () => { ); }); -test(' - renders a wrapper with unknown props', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('div').at(0).prop('data-x')).toBe('x'); - expect(wrapper.find('div').at(0).prop('data-y')).toBe('y'); - expect(wrapper.find('div').at(0).prop('data-z')).toBe('z'); -}); - -test(' - works with special characters', () => { - mount( - , - createContext({ x: { type: String, allowedValues: ['ă', 'ș'] } }), - ); -}); - test(' - disabled items (options) based on predicate', () => { const element = ( - disabled items (options) based on predicate', () => { expect(wrapper.find('option[value="b"]').at(0).prop('disabled')).toBe(false); }); -test(' - renders a select with correct value (default)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toStrictEqual([]); -}); - -test(' - renders a select with correct value (model)', () => { - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { model: { x: ['b'] } }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toStrictEqual(['b']); -}); - -test(' - renders a select with correct value (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect(wrapper.find('select').prop('value')).toStrictEqual(['b']); -}); - test(' - renders a select which correctly reacts on change (first value)', () => { const onChange = jest.fn(); @@ -403,307 +79,6 @@ test(' - renders a select which correctly reacts on change (next va expect(onChange).toHaveBeenLastCalledWith('x', ['a', 'b']); }); -test(' - renders a select which correctly reacts on change (uncheck) by value', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper.find('select').simulate('change', { target: { value: 'a' } }), - ).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', []); -}); - -test(' - renders a select which correctly reacts on change (uncheck) by selectedIndex', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('select')).toHaveLength(1); - expect( - wrapper - .find('select') - .simulate('change', { target: { selectedIndex: -1 } }), - ).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', []); -}); - -test(' - renders a set of checkboxes', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); -}); - -test(' - renders a set of checkboxes with correct disabled state', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('disabled')).toBe(true); - expect(wrapper.find('input').at(1).prop('disabled')).toBe(true); -}); - -test(' - renders a set of checkboxes with correct readOnly state', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).not.toHaveBeenCalled(); -}); - -test(' - renders a set of checkboxes with correct id (inherited)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('id')).toBeTruthy(); - expect(wrapper.find('input').at(1).prop('id')).toBeTruthy(); -}); - -test(' - renders a set of checkboxes with correct id (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('id')).toBe('y-YQ'); - expect(wrapper.find('input').at(1).prop('id')).toBe('y-Yg'); -}); - -test(' - renders a set of checkboxes with correct name', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('name')).toBe('x'); - expect(wrapper.find('input').at(1).prop('name')).toBe('x'); -}); - -test(' - renders a set of checkboxes with correct options', () => { - const element = ; - const wrapper = mount( - element, - createContext({ - x: { type: String, allowedValues: ['a', 'b'], label: '' }, - }), - ); - - expect(wrapper.find('label')).toHaveLength(2); - expect(wrapper.find('label').at(0).text()).toBe('a'); - expect(wrapper.find('label').at(1).text()).toBe('b'); -}); - -test(' - renders a set of checkboxes with correct options (transform)', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ x: { type: String, label: '' } }), - ); - - expect(wrapper.find('label')).toHaveLength(2); - expect(wrapper.find('label').at(0).text()).toBe('A'); - expect(wrapper.find('label').at(1).text()).toBe('B'); -}); - -test(' - renders a set of checkboxes with correct value (default)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(false); -}); - -test(' - renders a set of checkboxes with correct value (model)', () => { - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' } }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(true); -}); - -test(' - renders a set of checkboxes with correct value (specified)', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).prop('checked')).toBe(false); - expect(wrapper.find('input').at(1).prop('checked')).toBe(true); -}); - -test(' - renders a set of checkboxes which correctly reacts on change', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'b'); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (array check)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', ['b']); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (array uncheck)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { - x: { type: Array }, - 'x.$': { type: String, allowedValues: ['a', 'b'] }, - }, - { onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(1).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', []); -}); - -test(' - renders a set of checkboxes which correctly reacts on change (same value)', () => { - const onChange = jest.fn(); - - const element = ; - const wrapper = mount( - element, - createContext( - { x: { type: String, allowedValues: ['a', 'b'] } }, - { model: { x: 'b' }, onChange }, - ), - ); - - expect(wrapper.find('input')).toHaveLength(2); - expect(wrapper.find('input').at(0).simulate('change')).toBeTruthy(); - expect(onChange).toHaveBeenLastCalledWith('x', 'a'); -}); - -test(' - renders a label', () => { - const element = ; - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('label')).toHaveLength(3); - expect(wrapper.find('label').at(0).text()).toBe('y'); -}); - -test(' - renders a wrapper with unknown props', () => { - const element = ( - - ); - const wrapper = mount( - element, - createContext({ x: { type: String, allowedValues: ['a', 'b'] } }), - ); - - expect(wrapper.find('div').at(0).prop('data-x')).toBe('x'); - expect(wrapper.find('div').at(0).prop('data-y')).toBe('y'); - expect(wrapper.find('div').at(0).prop('data-z')).toBe('z'); -}); - -test(' - works with special characters', () => { - mount( - , - createContext({ x: { type: String, allowedValues: ['ă', 'ș'] } }), - ); -}); - test(' - renders correct error text (specified)', () => { const error = new Error(); const element = ( diff --git a/packages/uniforms-unstyled/__tests__/_createContext.ts b/packages/uniforms-unstyled/__tests__/_createContext.ts deleted file mode 100644 index e687bc994..000000000 --- a/packages/uniforms-unstyled/__tests__/_createContext.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { SimpleSchemaDefinition } from 'simpl-schema'; -import { Context, UnknownObject, randomIds, ChangedMap } from 'uniforms'; - -import createSchema from './_createSchema'; - -const randomId = randomIds(); - -export default function createContext( - schema?: SimpleSchemaDefinition, - context?: Partial>, - model = {} as Model, -): { context: Context } { - return { - context: { - changed: false, - changedMap: {} as ChangedMap, - error: null, - model, - name: [], - onChange() {}, - onSubmit() {}, - randomId, - submitted: false, - submitting: false, - validating: false, - ...context, - schema: createSchema(schema), - state: { - disabled: false, - readOnly: false, - showInlineError: false, - ...context?.state, - }, - // @ts-expect-error We don't have a true ref in tests. - formRef: null, - }, - }; -} diff --git a/packages/uniforms-unstyled/__tests__/_createSchema.ts b/packages/uniforms-unstyled/__tests__/_createSchema.ts deleted file mode 100644 index 6ac1ef72b..000000000 --- a/packages/uniforms-unstyled/__tests__/_createSchema.ts +++ /dev/null @@ -1,6 +0,0 @@ -import SimpleSchema, { SimpleSchemaDefinition } from 'simpl-schema'; -import { SimpleSchema2Bridge } from 'uniforms-bridge-simple-schema-2'; - -export default function createSchema(schema: SimpleSchemaDefinition = {}) { - return new SimpleSchema2Bridge({ schema: new SimpleSchema(schema) }); -} diff --git a/packages/uniforms-unstyled/__tests__/_mount.tsx b/packages/uniforms-unstyled/__tests__/_mount.tsx deleted file mode 100644 index d586e42dd..000000000 --- a/packages/uniforms-unstyled/__tests__/_mount.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { mount as enzyme } from 'enzyme'; -import { context } from 'uniforms'; - -function mount(node: any, options: any) { - if (options === undefined) { - return enzyme(node); - } - return enzyme(node, { - wrappingComponent: context.Provider, - wrappingComponentProps: { value: options.context }, - }); -} - -export default mount as typeof enzyme;