Skip to content

Commit baba309

Browse files
committed
Add tests
1 parent b6b55b5 commit baba309

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

packages/mui-component-mapper/src/tests/form-fields.test.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { mount } from 'enzyme';
3+
import { act } from 'react-dom/test-utils';
34
import { FormLabel } from '@material-ui/core';
45
import MultipleChoiceListCommon from '@data-driven-forms/common/src/multiple-choice-list';
56
import FormRenderer, { componentTypes, validatorTypes } from '@data-driven-forms/react-form-renderer';
@@ -98,7 +99,39 @@ describe('formFields', () => {
9899
).toEqual(errorText);
99100
});
100101

101-
it('renders with helperText', () => {
102+
it('renders with warning', async () => {
103+
const errorField = {
104+
...field,
105+
validate: [{ type: validatorTypes.REQUIRED, warning: true }],
106+
useWarnings: true
107+
};
108+
let wrapper;
109+
110+
await act(async () => {
111+
wrapper = mount(
112+
<RendererWrapper
113+
schema={{
114+
fields: [errorField, { name: 'error-reset-touched', component: componentTypes.TEXT_FIELD, validate: [{ type: 'required' }] }]
115+
}}
116+
/>
117+
);
118+
});
119+
wrapper.update();
120+
121+
await act(async () => {
122+
wrapper.find('form').simulate('submit');
123+
});
124+
wrapper.update();
125+
126+
expect(
127+
wrapper
128+
.find('.MuiFormHelperText-root')
129+
.first()
130+
.text()
131+
).toEqual(errorText);
132+
});
133+
134+
it('renders with helperText', async () => {
102135
const helpertextField = {
103136
...field,
104137
helperText

0 commit comments

Comments
 (0)