diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index fe84dfe90..191a56dc9 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1 +1 @@
-* @radekmie @wadamek65
+* @wadamek65 @kestarumper
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 23d5cfac2..d5ea7fe2f 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -1,5 +1,6 @@
name: CI
on:
+ workflow_dispatch:
pull_request:
push:
branches:
diff --git a/docs/uth-autofield-algorithm.md b/docs/uth-autofield-algorithm.md
index 158bea9d0..8e14e70a0 100644
--- a/docs/uth-autofield-algorithm.md
+++ b/docs/uth-autofield-algorithm.md
@@ -46,7 +46,7 @@ const AutoField = createAutoField(props => {
## Overriding `AutoField`
-To make it possible, all `AutoFields` created with the `createAutoField` are configurable. To adjust the components, use the React context available in `AutoField.componentDetectorContext`. You can use it as often as needed - in most apps once will be enough. Example:
+If you want to alter the default behavior of `AutoField` and render a different component based on the props, you can do it using the React context available in `AutoField.componentDetectorContext`. You can use it as often as needed - once will be enough in most apps. Example:
```tsx
/* ... */}>
@@ -54,7 +54,7 @@ To make it possible, all `AutoFields` created with the `createAutoField` are con
```
-If you want to add an exception and then fallback to the existing algorithm, use `AutoField.defaultComponentDetector`. Example:
+If you want to change the detector only partially, i.e., to render one additional field, and in other cases, use the default algorithm as a fallback, return `AutoField.defaultComponentDetector`. Example:
```tsx
- renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label and info (specified)', () => {
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(Tooltip)).toHaveLength(1);
- expect(wrapper.find(Tooltip).prop('title')).toBe('ListFieldInfo');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('div > div').at(0).text()).toEqual(
- expect.stringContaining('ListFieldLabel'),
- );
-});
-
-test(' - renders correct numer of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find('input')).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array, label: '' }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('div > div').at(0).text()).toBe('Error');
-});
-
-test(' - renders correct error style', () => {
- const error = new Error();
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('div').at(0).prop('style')).toHaveProperty(
- 'borderColor',
- 'rgb(255, 85, 0)',
- );
-});
-
-test(' - renders correct error style (with specified style prop)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('div').at(0).prop('style')).toHaveProperty(
- 'marginLeft',
- '8px',
- );
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
-
- expect(wrapper.find(ListAddField).simulate('click')).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-antd/__tests__/ListItemField.tsx b/packages/uniforms-antd/__tests__/ListItemField.tsx
deleted file mode 100644
index 1a68cea18..000000000
--- a/packages/uniforms-antd/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-antd';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-antd/__tests__/TextField.tsx b/packages/uniforms-antd/__tests__/TextField.tsx
deleted file mode 100644
index fcaaa22ec..000000000
--- a/packages/uniforms-antd/__tests__/TextField.tsx
+++ /dev/null
@@ -1,193 +0,0 @@
-import { screen } from '@testing-library/react';
-import Input from 'antd/lib/input';
-import React from 'react';
-import { TextField } from 'uniforms-antd';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders component with unknown props', () => {
- const props = {
- 'data-x': 'x',
- 'data-y': 'y',
- 'data-z': 'z',
- };
- render(, { x: String });
-
- const input = screen.getByRole('textbox');
- Object.entries(props).forEach(([key, value]) =>
- expect(input).toHaveAttribute(key, value),
- );
- });
-});
-
-test(' - renders an input', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
-});
-
-test(' - renders an input with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('disabled')).toBe(true);
-});
-
-test(' - renders an input with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('readOnly')).toBe(true);
-});
-
-test(' - renders an input with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('id')).toBeTruthy();
-});
-
-test(' - renders an input with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('id')).toBe('y');
-});
-
-test(' - renders an input with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('name')).toBe('x');
-});
-
-test(' - renders an input with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('placeholder')).toBe('y');
-});
-
-test(' - renders an input with correct type', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('type')).toBe('text');
-});
-
-test(' - renders an input with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('value')).toBe('');
-});
-
-test(' - renders an input with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('value')).toBe('y');
-});
-
-test(' - renders an input with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(wrapper.find(Input).prop('value')).toBe('y');
-});
-
-test(' - renders an input which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(
- wrapper.find(Input).simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders an input which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(
- wrapper.find(Input).simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders an input which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find(Input)).toHaveLength(1);
- expect(
- wrapper.find(Input).simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toBe('y');
-});
-
-test(' - renders a wrapper with unknown props', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input).prop('data-x')).toBe('x');
- expect(wrapper.find(Input).prop('data-y')).toBe('y');
- expect(wrapper.find(Input).prop('data-z')).toBe('z');
-});
-
-test(' - renders a input with correct type prop', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input).prop('type')).toBe('password');
-});
-
-test(' - renders a input with autocomplete turned off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(Input).prop('autoComplete')).toBe('off');
-});
diff --git a/packages/uniforms-antd/__tests__/index.ts b/packages/uniforms-antd/__tests__/index.ts
index 152e18a14..717b7a7a2 100644
--- a/packages/uniforms-antd/__tests__/index.ts
+++ b/packages/uniforms-antd/__tests__/index.ts
@@ -47,7 +47,10 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByRole('img', { name: 'plus-square' }),
+ testTooltip: true,
+ testStyle: true,
});
+ suites.testListItemField(theme.ListItemField);
suites.testLongTextField(theme.LongTextField);
// FIXME: AntD number input doesn't work with new RTL test implementation
// suites.testNumField(antd.NumField);
diff --git a/packages/uniforms-bootstrap3/__tests__/ListField.tsx b/packages/uniforms-bootstrap3/__tests__/ListField.tsx
deleted file mode 100644
index 81e67ced7..000000000
--- a/packages/uniforms-bootstrap3/__tests__/ListField.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-bootstrap3';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toEqual(
- expect.stringContaining('ListFieldLabel'),
- );
-});
-
-test(' - renders correct numer of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find('input')).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.help-block').text()).toBe('Error');
-});
-
-test(' - renders correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.help-block')).toHaveLength(0);
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
-
- expect(wrapper.find(ListAddField).simulate('click')).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-bootstrap3/__tests__/ListItemField.tsx b/packages/uniforms-bootstrap3/__tests__/ListItemField.tsx
deleted file mode 100644
index b8f55cafb..000000000
--- a/packages/uniforms-bootstrap3/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-bootstrap3';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-bootstrap3/__tests__/TextField.tsx b/packages/uniforms-bootstrap3/__tests__/TextField.tsx
deleted file mode 100644
index 749c200de..000000000
--- a/packages/uniforms-bootstrap3/__tests__/TextField.tsx
+++ /dev/null
@@ -1,189 +0,0 @@
-import { screen } from '@testing-library/react';
-import React from 'react';
-import { TextField } from 'uniforms-bootstrap3';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders a wrapper with unknown props', () => {
- const props = {
- 'data-x': 'x',
- 'data-y': 'y',
- 'data-z': 'z',
- };
- render(, { x: String });
-
- const wrapper = screen.getByRole('textbox').closest('div');
- Object.entries(props).forEach(([key, value]) =>
- expect(wrapper).toHaveAttribute(key, value),
- );
- });
-});
-
-test(' - renders an input', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
-});
-
-test(' - renders an input with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('disabled')).toBe(true);
-});
-
-test(' - renders an input with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('readOnly')).toBe(true);
-});
-
-test(' - renders an input with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBeTruthy();
-});
-
-test(' - renders an input with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBe('y');
-});
-
-test(' - renders an input with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('name')).toBe('x');
-});
-
-test(' - renders an input with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('placeholder')).toBe('y');
-});
-
-test(' - renders an input with correct type', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('type')).toBe('text');
-});
-
-test(' - renders an input with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('');
-});
-
-test(' - renders an input with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders an input which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders an input which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toBe('y');
- expect(wrapper.find('label').prop('htmlFor')).toBe(
- wrapper.find('input').prop('id'),
- );
-});
-
-test(' - renders a wrapper with unknown props', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- 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(' - renders a input with autocomplete turned off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('div').at(0).prop('autoComplete')).toBeFalsy();
- expect(wrapper.find('input').prop('autoComplete')).toBe('off');
-});
diff --git a/packages/uniforms-bootstrap3/__tests__/index.ts b/packages/uniforms-bootstrap3/__tests__/index.ts
index e2fb15f9e..73501bc3f 100644
--- a/packages/uniforms-bootstrap3/__tests__/index.ts
+++ b/packages/uniforms-bootstrap3/__tests__/index.ts
@@ -47,7 +47,9 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByRole('button'),
+ disableInlineError: true,
});
+ suites.testListItemField(theme.ListItemField);
suites.testLongTextField(theme.LongTextField);
suites.testNestField(theme.NestField);
suites.testNumField(theme.NumField);
@@ -58,7 +60,7 @@ describe('@RTL', () => {
screen.getByLabelText('a').closest('.checkbox-inline'),
});
suites.testSubmitField(theme.SubmitField);
- suites.testTextField(theme.TextField);
+ suites.testTextField(theme.TextField, { testWrapClassName: true });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
diff --git a/packages/uniforms-bootstrap4/__tests__/ListField.tsx b/packages/uniforms-bootstrap4/__tests__/ListField.tsx
deleted file mode 100644
index 4f6215222..000000000
--- a/packages/uniforms-bootstrap4/__tests__/ListField.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-bootstrap4';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toEqual(
- expect.stringContaining('ListFieldLabel'),
- );
-});
-
-test(' - renders correct numer of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find('input')).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.text-danger').text()).toBe('Error');
-});
-
-test(' - renders correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.text-danger')).toHaveLength(0);
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
-
- expect(wrapper.find(ListAddField).simulate('click')).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-bootstrap4/__tests__/ListItemField.tsx b/packages/uniforms-bootstrap4/__tests__/ListItemField.tsx
deleted file mode 100644
index 3bc76866e..000000000
--- a/packages/uniforms-bootstrap4/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-bootstrap4';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-bootstrap4/__tests__/TextField.tsx b/packages/uniforms-bootstrap4/__tests__/TextField.tsx
deleted file mode 100644
index 666bfc861..000000000
--- a/packages/uniforms-bootstrap4/__tests__/TextField.tsx
+++ /dev/null
@@ -1,189 +0,0 @@
-import { screen } from '@testing-library/react';
-import React from 'react';
-import { TextField } from 'uniforms-bootstrap4';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders a wrapper with unknown props', () => {
- const props = {
- 'data-x': 'x',
- 'data-y': 'y',
- 'data-z': 'z',
- };
- render(, { x: String });
-
- const wrapper = screen.getByRole('textbox').closest('div');
- Object.entries(props).forEach(([key, value]) =>
- expect(wrapper).toHaveAttribute(key, value),
- );
- });
-});
-
-test(' - renders an input', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
-});
-
-test(' - renders an input with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('disabled')).toBe(true);
-});
-
-test(' - renders an input with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('readOnly')).toBe(true);
-});
-
-test(' - renders an input with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBeTruthy();
-});
-
-test(' - renders an input with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBe('y');
-});
-
-test(' - renders an input with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('name')).toBe('x');
-});
-
-test(' - renders an input with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('placeholder')).toBe('y');
-});
-
-test(' - renders an input with correct type', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('type')).toBe('text');
-});
-
-test(' - renders an input with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('');
-});
-
-test(' - renders an input with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders an input which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders an input which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toBe('y');
- expect(wrapper.find('label').prop('htmlFor')).toBe(
- wrapper.find('input').prop('id'),
- );
-});
-
-test(' - renders a wrapper with unknown props', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- 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(' - renders a input with autocomplete turned off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('div').at(0).prop('autoComplete')).toBeFalsy();
- expect(wrapper.find('input').prop('autoComplete')).toBe('off');
-});
diff --git a/packages/uniforms-bootstrap4/__tests__/index.ts b/packages/uniforms-bootstrap4/__tests__/index.ts
index b52f247ab..74eb7b3de 100644
--- a/packages/uniforms-bootstrap4/__tests__/index.ts
+++ b/packages/uniforms-bootstrap4/__tests__/index.ts
@@ -47,7 +47,9 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByRole('button'),
+ disableInlineError: true,
});
+ suites.testListItemField(theme.ListItemField);
suites.testLongTextField(theme.LongTextField);
suites.testNestField(theme.NestField);
suites.testNumField(theme.NumField);
@@ -58,7 +60,7 @@ describe('@RTL', () => {
screen.getByLabelText('a').closest('.checkbox-inline'),
});
suites.testSubmitField(theme.SubmitField);
- suites.testTextField(theme.TextField);
+ suites.testTextField(theme.TextField, { testWrapClassName: true });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
diff --git a/packages/uniforms-bootstrap5/__tests__/ListField.tsx b/packages/uniforms-bootstrap5/__tests__/ListField.tsx
deleted file mode 100644
index 72efa14fc..000000000
--- a/packages/uniforms-bootstrap5/__tests__/ListField.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-bootstrap5';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toEqual(
- expect.stringContaining('ListFieldLabel'),
- );
-});
-
-test(' - renders correct numer of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find('input')).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.text-danger').text()).toBe('Error');
-});
-
-test(' - renders correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('.text-danger')).toHaveLength(0);
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
-
- expect(wrapper.find(ListAddField).simulate('click')).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-bootstrap5/__tests__/ListItemField.tsx b/packages/uniforms-bootstrap5/__tests__/ListItemField.tsx
deleted file mode 100644
index c105a0ba2..000000000
--- a/packages/uniforms-bootstrap5/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-bootstrap5';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-bootstrap5/__tests__/TextField.tsx b/packages/uniforms-bootstrap5/__tests__/TextField.tsx
deleted file mode 100644
index aee886918..000000000
--- a/packages/uniforms-bootstrap5/__tests__/TextField.tsx
+++ /dev/null
@@ -1,200 +0,0 @@
-import { screen } from '@testing-library/react';
-import React from 'react';
-import { TextField } from 'uniforms-bootstrap5';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders a wrapper with unknown props', () => {
- const props = {
- 'data-x': 'x',
- 'data-y': 'y',
- 'data-z': 'z',
- };
- render(, { x: String });
-
- const wrapper = screen.getByRole('textbox').closest('div');
- Object.entries(props).forEach(([key, value]) =>
- expect(wrapper).toHaveAttribute(key, value),
- );
- });
-});
-
-test(' - renders an input', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
-});
-
-test(' - renders an input with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('disabled')).toBe(true);
-});
-
-test(' - renders an input with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('readOnly')).toBe(true);
-});
-
-test(' - renders an input with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBeTruthy();
-});
-
-test(' - renders an input with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBe('y');
-});
-
-test(' - renders an input with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('name')).toBe('x');
-});
-
-test(' - renders an input with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('placeholder')).toBe('y');
-});
-
-test(' - renders an input with correct type', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('type')).toBe('text');
-});
-
-test(' - renders an input with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('');
-});
-
-test(' - renders an input with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('y');
-});
-
-test(' - renders an input which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders an input which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders an input which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toBe('y');
- expect(wrapper.find('label').prop('htmlFor')).toBe(
- wrapper.find('input').prop('id'),
- );
-});
-
-test(' - renders a wrapper with unknown props', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- 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(' - renders a input with autocomplete turned off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('div').at(0).prop('autoComplete')).toBeFalsy();
- expect(wrapper.find('input').prop('autoComplete')).toBe('off');
-});
-
-test(' - renders a input with minLength and maxLength', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('div').at(0).prop('minLength')).toBeFalsy();
- expect(wrapper.find('input').prop('minLength')).toBe(1);
-
- expect(wrapper.find('div').at(0).prop('maxLength')).toBeFalsy();
- expect(wrapper.find('input').prop('maxLength')).toBe(10);
-});
diff --git a/packages/uniforms-bootstrap5/__tests__/index.ts b/packages/uniforms-bootstrap5/__tests__/index.ts
index d155ffd98..374958d94 100644
--- a/packages/uniforms-bootstrap5/__tests__/index.ts
+++ b/packages/uniforms-bootstrap5/__tests__/index.ts
@@ -47,7 +47,9 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByRole('button'),
+ disableInlineError: true,
});
+ suites.testListItemField(theme.ListItemField);
suites.testLongTextField(theme.LongTextField, {
testMinMaxLength: true,
});
@@ -60,7 +62,10 @@ describe('@RTL', () => {
screen.getByLabelText('a').closest('.form-check-inline'),
});
suites.testSubmitField(theme.SubmitField);
- suites.testTextField(theme.TextField);
+ suites.testTextField(theme.TextField, {
+ testWrapClassName: true,
+ testMinMaxLength: true,
+ });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
diff --git a/packages/uniforms-material/__tests__/ListField.tsx b/packages/uniforms-material/__tests__/ListField.tsx
deleted file mode 100644
index 046235db6..000000000
--- a/packages/uniforms-material/__tests__/ListField.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import IconButton from '@material-ui/core/IconButton';
-import ListSubheader from '@material-ui/core/ListSubheader';
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-material';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListSubheader)).toHaveLength(1);
- expect(wrapper.find(ListSubheader).text()).toBe('ListFieldLabel');
-});
-
-test(' - renders correct number of items with model', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
- expect(
- wrapper.find(ListAddField).find(IconButton).simulate('click'),
- ).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-material/__tests__/ListItemField.tsx b/packages/uniforms-material/__tests__/ListItemField.tsx
deleted file mode 100644
index 996d39dbb..000000000
--- a/packages/uniforms-material/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-material';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-material/__tests__/LongTextField.tsx b/packages/uniforms-material/__tests__/LongTextField.tsx
deleted file mode 100644
index 9c2708667..000000000
--- a/packages/uniforms-material/__tests__/LongTextField.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
-import ThemeProvider from '@material-ui/styles/ThemeProvider/ThemeProvider';
-import React from 'react';
-import { LongTextField } from 'uniforms-material';
-import { renderWithZod } from 'uniforms/__suites__';
-import z from 'zod';
-
-describe('@RTL - LongTextField tests', () => {
- test(' - default props are not passed when MUI theme props are specified', () => {
- const theme = createMuiTheme({
- props: { MuiTextField: { fullWidth: false, margin: 'normal' } },
- });
-
- const { container } = renderWithZod({
- element: (
-
-
-
- ),
- schema: z.object({ x: z.string() }),
- });
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginNormal',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).not.toHaveClass('MuiFormControl-fullWidth');
- });
-
- test(' - default props are passed when MUI theme props are absent', () => {
- const theme = createMuiTheme({});
-
- const { container } = renderWithZod({
- element: (
-
-
-
- ),
- schema: z.object({ x: z.string() }),
- });
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginDense',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).toHaveClass('MuiFormControl-fullWidth');
- });
-
- test(' - explicit props are passed when MUI theme props are specified', () => {
- const theme = createMuiTheme({
- props: { MuiTextField: { fullWidth: true, margin: 'dense' } },
- });
- const explicitProps = {
- fullWidth: false,
- margin: 'normal' as const,
- };
-
- const { container } = renderWithZod({
- element: (
-
-
-
- ),
- schema: z.object({ x: z.string() }),
- });
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginNormal',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).not.toHaveClass('MuiFormControl-fullWidth');
- });
-});
diff --git a/packages/uniforms-material/__tests__/TextField.tsx b/packages/uniforms-material/__tests__/TextField.tsx
deleted file mode 100644
index bda931460..000000000
--- a/packages/uniforms-material/__tests__/TextField.tsx
+++ /dev/null
@@ -1,272 +0,0 @@
-import TextFieldMaterial from '@material-ui/core/TextField';
-import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
-import ThemeProvider from '@material-ui/styles/ThemeProvider/ThemeProvider';
-import { screen } from '@testing-library/react';
-import React from 'react';
-import { TextField } from 'uniforms-material';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders a TextField with correct error text (specified)', () => {
- const errorMessage = 'Error';
- render(
- ,
- { x: String },
- );
-
- expect(screen.getByText(errorMessage)).toBeInTheDocument();
- });
-
- test(' - renders a TextField with correct error text (showInlineError=false)', () => {
- const errorMessage = 'Error';
- render(
- ,
- { x: String },
- );
-
- expect(screen.queryByText(errorMessage)).not.toBeInTheDocument();
- });
-
- test(' - default props are not passed when MUI theme props are specified', () => {
- const theme = createMuiTheme({
- props: { MuiTextField: { fullWidth: false, margin: 'normal' } },
- });
- const { container } = render(
-
-
- ,
- { x: { type: String } },
- );
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginNormal',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).not.toHaveClass('MuiFormControl-fullWidth');
- });
-
- test(' - default props are passed when MUI theme props are absent', () => {
- const theme = createMuiTheme({});
- const { container } = render(
-
-
- ,
- { x: { type: String } },
- );
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginDense',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).toHaveClass('MuiFormControl-fullWidth');
- });
-
- test(' - explicit props are passed when MUI theme props are specified', () => {
- const theme = createMuiTheme({
- props: { MuiTextField: { fullWidth: true, margin: 'dense' } },
- });
- const explicitProps = {
- fullWidth: false,
- margin: 'normal' as const,
- };
-
- const { container } = render(
-
-
- ,
- { x: { type: String } },
- );
-
- const elements = container.getElementsByClassName(
- 'MuiFormControl-marginNormal',
- );
- expect(elements).toHaveLength(1);
- expect(elements[0]).not.toHaveClass('MuiFormControl-fullWidth');
- });
-});
-
-test(' - renders an TextField', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
-});
-
-test(' - renders a TextField with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('disabled')).toBe(true);
-});
-
-test(' - renders a TextField with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('inputProps')!.readOnly).toBe(
- true,
- );
-});
-
-test(' - renders a TextField with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('id')).toBeTruthy();
-});
-
-test(' - renders a TextField with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('id')).toBe('y');
-});
-
-test(' - renders a TextField with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('name')).toBe('x');
-});
-
-test(' - renders a TextField with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('placeholder')).toBe('y');
-});
-
-test(' - renders a TextField with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('');
-});
-
-test(' - renders a TextField with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('y');
-});
-
-test(' - renders a TextField with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('y');
-});
-
-test(' - renders a TextField which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a TextField which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders a TextField which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('label')).toBe('y');
-});
-
-test(' - renders a TextField with correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial).prop('helperText')).toBe('Error');
-});
-
-test(' - renders a TextField with correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial).prop('helperText')).toBeUndefined();
-});
-
-test(' - renders a input with autocomplete off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('autoComplete')).toBe('off');
-});
diff --git a/packages/uniforms-material/__tests__/index.ts b/packages/uniforms-material/__tests__/index.tsx
similarity index 68%
rename from packages/uniforms-material/__tests__/index.ts
rename to packages/uniforms-material/__tests__/index.tsx
index fbe8f1a7b..647461ce5 100644
--- a/packages/uniforms-material/__tests__/index.ts
+++ b/packages/uniforms-material/__tests__/index.tsx
@@ -1,3 +1,8 @@
+import createMuiTheme, {
+ ThemeOptions,
+} from '@material-ui/core/styles/createMuiTheme';
+import ThemeProvider from '@material-ui/styles/ThemeProvider/ThemeProvider';
+import React, { PropsWithChildren } from 'react';
import * as theme from 'uniforms-material';
import * as suites from 'uniforms/__suites__';
@@ -49,8 +54,23 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByText(/\+/),
+ testError: false,
+ });
+ suites.testListItemField(theme.ListItemField);
+ suites.testLongTextField(theme.LongTextField, {
+ testPassThemeProps: {
+ ThemeProvider({
+ themeOptions,
+ ...props
+ }: PropsWithChildren<{ themeOptions: ThemeOptions }>) {
+ return (
+
+ {props.children}
+
+ );
+ },
+ },
});
- suites.testLongTextField(theme.LongTextField);
suites.testNestField(theme.NestField, { skipInMuiTests: true });
suites.testNumField(theme.NumField);
suites.testQuickForm(theme.QuickForm);
@@ -58,7 +78,21 @@ describe('@RTL', () => {
// FIXME: MUI select does not work with new RTL test implementation
// suites.testSelectField(theme.SelectField);
suites.testSubmitField(theme.SubmitField);
- suites.testTextField(theme.TextField);
+ suites.testTextField(theme.TextField, {
+ testShowInlineError: true,
+ testPassThemeProps: {
+ ThemeProvider({
+ themeOptions,
+ ...props
+ }: PropsWithChildren<{ themeOptions: ThemeOptions }>) {
+ return (
+
+ {props.children}
+
+ );
+ },
+ },
+ });
suites.testValidatedForm(theme.ValidatedForm);
suites.testValidatedQuickForm(theme.ValidatedQuickForm);
});
diff --git a/packages/uniforms-mui/__tests__/ListField.tsx b/packages/uniforms-mui/__tests__/ListField.tsx
deleted file mode 100644
index 4c10074d0..000000000
--- a/packages/uniforms-mui/__tests__/ListField.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import IconButton from '@mui/material/IconButton';
-import ListSubheader from '@mui/material/ListSubheader';
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-mui';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListSubheader)).toHaveLength(1);
- expect(wrapper.find(ListSubheader).text()).toBe('ListFieldLabel');
-});
-
-test(' - renders correct number of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-// Strange enzyme behavior
-// TypeError: Cannot read properties of null (reading '__reactFiber$my72orhzzz9')
-test.skip(' - renders proper number of optional values after add new value (with initialCount)', async () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- ),
- );
-
- expect(
- wrapper.find(ListAddField).find(IconButton).simulate('click'),
- ).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-mui/__tests__/ListItemField.tsx b/packages/uniforms-mui/__tests__/ListItemField.tsx
deleted file mode 100644
index 25de0fd8e..000000000
--- a/packages/uniforms-mui/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-mui';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-mui/__tests__/TextField.tsx b/packages/uniforms-mui/__tests__/TextField.tsx
deleted file mode 100644
index ae18aca3d..000000000
--- a/packages/uniforms-mui/__tests__/TextField.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-import TextFieldMaterial from '@mui/material/TextField';
-import React from 'react';
-import { TextField } from 'uniforms-mui';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - renders an TextField', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
-});
-
-test(' - renders a TextField with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('disabled')).toBe(true);
-});
-
-test(' - renders a TextField with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('inputProps')!.readOnly).toBe(
- true,
- );
-});
-
-test(' - renders a TextField with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('id')).toBeTruthy();
-});
-
-test(' - renders a TextField with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('id')).toBe('y');
-});
-
-test(' - renders a TextField with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('name')).toBe('x');
-});
-
-test(' - renders a TextField with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('placeholder')).toBe('y');
-});
-
-test(' - renders a TextField with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('');
-});
-
-test(' - renders a TextField with correct value (model)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' } }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('y');
-});
-
-test(' - renders a TextField with correct value (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('value')).toBe('y');
-});
-
-test(' - renders a TextField which correctly reacts on change', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a TextField which correctly reacts on change (empty)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: '' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', '');
-});
-
-test(' - renders a TextField which correctly reacts on change (same value)', () => {
- const onChange = jest.fn();
-
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: String } }, { model: { x: 'y' }, onChange }),
- );
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(
- wrapper.find('input').simulate('change', { target: { value: 'y' } }),
- ).toBeTruthy();
- expect(onChange).toHaveBeenLastCalledWith('x', 'y');
-});
-
-test(' - renders a label', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('label')).toBe('y');
-});
-
-test(' - renders a TextField with correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial).prop('helperText')).toBe('Error');
-});
-
-test(' - renders a TextField with correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial).prop('helperText')).toBeUndefined();
-});
-
-test(' - renders a input with autocomplete off', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find(TextFieldMaterial)).toHaveLength(1);
- expect(wrapper.find(TextFieldMaterial).prop('autoComplete')).toBe('off');
-});
diff --git a/packages/uniforms-mui/__tests__/index.ts b/packages/uniforms-mui/__tests__/index.ts
index 2b7520252..634b6f46f 100644
--- a/packages/uniforms-mui/__tests__/index.ts
+++ b/packages/uniforms-mui/__tests__/index.ts
@@ -46,7 +46,9 @@ describe('@RTL', () => {
suites.testListDelField(theme.ListDelField);
suites.testListField(theme.ListField, {
getListAddField: screen => screen.getByText(/\+/),
+ testError: false,
});
+ suites.testListItemField(theme.ListItemField);
suites.testLongTextField(theme.LongTextField);
suites.testNestField(theme.NestField, { skipInMuiTests: true });
suites.testNumField(theme.NumField);
diff --git a/packages/uniforms-semantic/__tests__/ListField.tsx b/packages/uniforms-semantic/__tests__/ListField.tsx
deleted file mode 100644
index 2efb22d0f..000000000
--- a/packages/uniforms-semantic/__tests__/ListField.tsx
+++ /dev/null
@@ -1,167 +0,0 @@
-import React from 'react';
-import { ListAddField, ListField, ListItemField } from 'uniforms-semantic';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListField)).toHaveLength(1);
-});
-
-test(' - renders ListAddField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListAddField)).toHaveLength(1);
- expect(wrapper.find(ListAddField).prop('name')).toBe('$');
-});
-
-test(' - renders correct label (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find('label')).toHaveLength(1);
- expect(wrapper.find('label').text()).toEqual(
- expect.stringContaining('ListFieldLabel'),
- );
-});
-
-test(' - renders correct number of items with model (specified)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined, undefined],
- }),
- );
-
- expect(wrapper.find('input')).toHaveLength(3);
-});
-
-test(' - passes itemProps to its children', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).first().prop('data-xyz')).toBe(1);
-});
-
-test(' - renders children (specified)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
- PlainText
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(Child).toHaveBeenCalledTimes(2);
-});
-
-test(' - renders children with correct name (children)', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(Child).at(0).prop('name')).toBe('0');
- expect(wrapper.find(Child).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders children with correct name (value)', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }, undefined, {
- x: [undefined, undefined],
- }),
- );
-
- expect(wrapper.find(ListItemField).at(0).prop('name')).toBe('0');
- expect(wrapper.find(ListItemField).at(1).prop('name')).toBe('1');
-});
-
-test(' - renders correct error text (specified)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array, label: '' }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.children().first().text()).toBe('Error');
-});
-
-test(' - renders correct error text (showInlineError=false)', () => {
- const error = new Error();
- const element = (
-
- );
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.children().first().text()).not.toBe('Error');
-});
-
-test(' - renders proper number of optional values after add new value', () => {
- const element = ;
- const onChange = jest.fn();
- const wrapper = mount(
- element,
- createContext(
- { x: { type: Array, optional: true }, 'x.$': { type: String } },
- { onChange },
- {
- x: [undefined, undefined, undefined],
- },
- ),
- );
- expect(wrapper.find(ListAddField).simulate('click')).toBeTruthy();
- expect(onChange).toHaveBeenNthCalledWith(1, 'x', [
- undefined,
- undefined,
- undefined,
- undefined,
- ]);
-});
diff --git a/packages/uniforms-semantic/__tests__/ListItemField.tsx b/packages/uniforms-semantic/__tests__/ListItemField.tsx
deleted file mode 100644
index 2c4224268..000000000
--- a/packages/uniforms-semantic/__tests__/ListItemField.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import { AutoField, ListDelField, ListItemField } from 'uniforms-semantic';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-test(' - works', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListItemField)).toHaveLength(1);
-});
-
-test(' - renders ListDelField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(ListDelField)).toHaveLength(1);
- expect(wrapper.find(ListDelField).childAt(0).prop('name')).toBe('x.1');
-});
-
-test(' - renders AutoField', () => {
- const element = ;
- const wrapper = mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(wrapper.find(AutoField)).toHaveLength(1);
-});
-
-test(' - renders children if specified', () => {
- const Child = jest.fn(() => ) as React.FC;
-
- const element = (
-
-
-
- );
- mount(
- element,
- createContext({ x: { type: Array }, 'x.$': { type: String } }),
- );
-
- expect(Child).toHaveBeenCalledTimes(1);
-});
diff --git a/packages/uniforms-semantic/__tests__/TextField.tsx b/packages/uniforms-semantic/__tests__/TextField.tsx
deleted file mode 100644
index 7f482bfed..000000000
--- a/packages/uniforms-semantic/__tests__/TextField.tsx
+++ /dev/null
@@ -1,284 +0,0 @@
-import { screen } from '@testing-library/react';
-import React from 'react';
-import { TextField } from 'uniforms-semantic';
-import { render } from 'uniforms/__suites__';
-
-import createContext from './_createContext';
-import mount from './_mount';
-
-describe('@RTL - TextField tests', () => {
- test(' - renders a wrapper with unknown props', () => {
- const props = {
- 'data-x': 'x',
- 'data-y': 'y',
- 'data-z': 'z',
- };
- render(, { x: String });
-
- const wrapper = screen.getByRole('textbox').closest('div')?.parentElement;
- Object.entries(props).forEach(([key, value]) =>
- expect(wrapper).toHaveAttribute(key, value),
- );
- });
-
- test(' - renders a TextField with correct error text (specified)', () => {
- const errorMessage = 'Error';
- render(
- ,
- { x: String },
- );
-
- expect(screen.getByText(errorMessage)).toBeInTheDocument();
- });
-
- test(' - renders a TextField with correct error text (showInlineError=false)', () => {
- const errorMessage = 'Error';
- render(
- ,
- { x: String },
- );
-
- expect(screen.queryByText(errorMessage)).not.toBeInTheDocument();
- });
-
- test(' - renders an icon', () => {
- const { container } = render(, {
- x: String,
- });
-
- expect(container.querySelector('i')).toBeInTheDocument();
- });
-
- test(' - renders with a custom wrapClassName', () => {
- const testClassName = 'test-class-name';
- render(, { x: String });
-
- expect(screen.getByRole('textbox').closest('div')).toHaveClass(
- testClassName,
- );
- });
-});
-
-test(' - renders an input', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
-});
-
-test(' - renders an input with correct disabled state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('disabled')).toBe(true);
-});
-
-test(' - renders an input with correct readOnly state', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('readOnly')).toBe(true);
-});
-
-test(' - renders an input with correct id (inherited)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBeTruthy();
-});
-
-test(' - renders an input with correct id (specified)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('id')).toBe('y');
-});
-
-test(' - renders an input with correct name', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('name')).toBe('x');
-});
-
-test(' - renders an input with correct placeholder', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('placeholder')).toBe('y');
-});
-
-test(' - renders an input with correct type', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('type')).toBe('text');
-});
-
-test(' - renders an input with correct value (default)', () => {
- const element = ;
- const wrapper = mount(element, createContext({ x: { type: String } }));
-
- expect(wrapper.find('input')).toHaveLength(1);
- expect(wrapper.find('input').prop('value')).toBe('');
-});
-
-test(' - renders an input with correct value (model)', () => {
- const element =