envoc-form 5.0.3 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -20
- package/es/ConfirmBaseForm/ConfirmBaseForm.js +2 -2
- package/es/DatePicker/DatePickerGroup.js +2 -2
- package/es/FieldArray/FieldArray.js +4 -4
- package/es/File/FileGroup.js +3 -3
- package/es/Form/Form.js +2 -2
- package/es/Group.js +3 -3
- package/es/Input/CheckboxGroup.d.ts +6 -0
- package/es/Input/CheckboxGroup.js +14 -0
- package/es/Input/CheckboxInputGroup.d.ts +13 -0
- package/es/Input/CheckboxInputGroup.js +41 -0
- package/es/Input/IconInputGroup.js +2 -2
- package/es/Input/InputGroup.js +2 -2
- package/es/Input/MoneyInputGroup.js +2 -2
- package/es/Input/NumberInputGroup.js +2 -2
- package/es/Input/PhoneNumberInputGroup.js +2 -2
- package/es/Input/StringInputGroup.js +2 -2
- package/es/Select/SelectGroup.js +3 -3
- package/es/StandardFormActions.js +3 -3
- package/es/SubmitFormButton.js +2 -2
- package/es/TextArea/TextAreaGroup.js +2 -2
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/lib/ConfirmBaseForm/ConfirmBaseForm.js +2 -5
- package/lib/DatePicker/DatePickerGroup.js +2 -2
- package/lib/FieldArray/FieldArray.js +4 -4
- package/lib/File/FileGroup.js +3 -3
- package/lib/Form/Form.js +2 -2
- package/lib/Group.js +3 -3
- package/lib/Input/CheckboxGroup.d.ts +6 -0
- package/lib/Input/CheckboxGroup.js +20 -0
- package/lib/Input/CheckboxInputGroup.d.ts +13 -0
- package/lib/Input/CheckboxInputGroup.js +46 -0
- package/lib/Input/IconInputGroup.js +2 -2
- package/lib/Input/InputGroup.js +2 -2
- package/lib/Input/MoneyInputGroup.js +2 -2
- package/lib/Input/NumberInputGroup.js +2 -2
- package/lib/Input/PhoneNumberInputGroup.js +2 -2
- package/lib/Input/StringInputGroup.js +2 -2
- package/lib/Select/SelectGroup.js +3 -3
- package/lib/StandardFormActions.js +3 -3
- package/lib/SubmitFormButton.js +2 -2
- package/lib/TextArea/TextAreaGroup.js +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/package.json +111 -111
- package/src/AddressInput/AddressInput.test.tsx +27 -27
- package/src/AddressInput/AddressInput.tsx +82 -82
- package/src/AddressInput/UsStates.ts +55 -55
- package/src/AddressInput/__snapshots__/AddressInput.test.tsx.snap +182 -182
- package/src/ConfirmBaseForm/ConfirmBaseForm.test.tsx +24 -24
- package/src/ConfirmBaseForm/ConfirmBaseForm.tsx +74 -74
- package/src/ConfirmBaseForm/__snapshots__/ConfirmBaseForm.test.tsx.snap +23 -23
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.test.tsx +24 -24
- package/src/ConfirmDeleteForm/ConfirmDeleteForm.tsx +87 -87
- package/src/ConfirmDeleteForm/__snapshots__/ConfirmDeleteForm.test.tsx.snap +25 -25
- package/src/DatePicker/DatePicker.test.tsx +48 -48
- package/src/DatePicker/DatePickerGroup.tsx +109 -115
- package/src/DatePicker/DatePickerHelper.ts +4 -4
- package/src/DatePicker/StringDateOnlyPickerGroup.tsx +28 -28
- package/src/DatePicker/StringDatePickerGroup.tsx +20 -20
- package/src/DatePicker/__snapshots__/DatePicker.test.tsx.snap +152 -152
- package/src/Field/CustomFieldInputProps.ts +10 -10
- package/src/Field/CustomFieldMetaProps.ts +5 -5
- package/src/Field/Field.tsx +113 -113
- package/src/Field/FieldErrorScrollTarget.tsx +12 -12
- package/src/Field/FieldNameContext.ts +6 -6
- package/src/Field/FieldSection.tsx +18 -18
- package/src/Field/InjectedFieldProps.ts +8 -8
- package/src/Field/StandAloneInput.tsx +55 -55
- package/src/Field/useStandardField.ts +125 -125
- package/src/FieldArray/FieldArray.tsx +154 -154
- package/src/File/FileGroup.test.tsx +35 -35
- package/src/File/FileGroup.tsx +82 -85
- package/src/File/FileList.tsx +21 -21
- package/src/File/__snapshots__/FileGroup.test.tsx.snap +34 -34
- package/src/File/humanFileSize.ts +8 -8
- package/src/Form/FocusError.tsx +55 -55
- package/src/Form/Form.test.tsx +14 -14
- package/src/Form/Form.tsx +234 -237
- package/src/Form/FormBasedPreventNavigation.tsx +56 -56
- package/src/Form/LegacyFormBasedPreventNavigation.tsx +77 -77
- package/src/Form/NewFormBasedPreventNavigation.tsx +59 -59
- package/src/Form/ServerErrorContext.ts +18 -18
- package/src/Form/__snapshots__/Form.test.tsx.snap +10 -10
- package/src/FormActions.tsx +47 -47
- package/src/FormDefaults.ts +2 -2
- package/src/Group.tsx +62 -62
- package/src/Input/CheckboxGroup.tsx +60 -0
- package/src/Input/CheckboxInputGroup.tsx +78 -0
- package/src/Input/IconInputGroup.tsx +54 -54
- package/src/Input/InputGroup.tsx +66 -72
- package/src/Input/MoneyInputGroup.tsx +47 -50
- package/src/Input/NumberInputGroup.tsx +45 -48
- package/src/Input/PhoneNumberInputGroup.tsx +45 -45
- package/src/Input/StringInputGroup.tsx +50 -53
- package/src/Input/__Tests__/CheckboxInputGroup.test.tsx +26 -0
- package/src/Input/__Tests__/IconInputGroup.test.tsx +35 -35
- package/src/Input/__Tests__/MoneyInputGroup.test.tsx +37 -37
- package/src/Input/__Tests__/NumberInputGroup.test.tsx +35 -35
- package/src/Input/__Tests__/PhoneNumberInputGroup.test.tsx +36 -36
- package/src/Input/__Tests__/StringInputGroup.test.tsx +27 -27
- package/src/Input/__Tests__/__snapshots__/CheckboxInputGroup.test.tsx.snap +33 -0
- package/src/Input/__Tests__/__snapshots__/IconInputGroup.test.tsx.snap +32 -32
- package/src/Input/__Tests__/__snapshots__/MoneyInputGroup.test.tsx.snap +34 -34
- package/src/Input/__Tests__/__snapshots__/NumberInputGroup.test.tsx.snap +32 -32
- package/src/Input/__Tests__/__snapshots__/PhoneNumberInputGroup.test.tsx.snap +33 -33
- package/src/Input/__Tests__/__snapshots__/StringInputGroup.test.tsx.snap +31 -31
- package/src/Normalization/NormalizationFunction.ts +4 -4
- package/src/Normalization/normalizers.ts +44 -44
- package/src/Select/BooleanSelectGroup.tsx +28 -28
- package/src/Select/NumberSelectGroup.tsx +16 -16
- package/src/Select/SelectGroup.tsx +124 -124
- package/src/Select/SelectGroupPropsHelper.ts +4 -4
- package/src/Select/StringSelectGroup.tsx +16 -16
- package/src/Select/__tests__/BooleanSelectGroup.test.tsx +35 -35
- package/src/Select/__tests__/NumberSelectGroup.test.tsx +87 -87
- package/src/Select/__tests__/StringSelectGroup.test.tsx +89 -89
- package/src/Select/__tests__/__snapshots__/BooleanSelectGroup.test.tsx.snap +98 -98
- package/src/Select/__tests__/__snapshots__/NumberSelectGroup.test.tsx.snap +195 -195
- package/src/Select/__tests__/__snapshots__/StringSelectGroup.test.tsx.snap +195 -195
- package/src/StandardFormActions.tsx +41 -41
- package/src/SubmitFormButton.tsx +54 -54
- package/src/TextArea/TextAreaGroup.tsx +64 -64
- package/src/Validation/ValidatedApiResult.ts +8 -8
- package/src/Validation/ValidationError.ts +6 -6
- package/src/Validation/ValidationFunction.ts +4 -4
- package/src/Validation/validators.test.tsx +81 -81
- package/src/Validation/validators.ts +97 -97
- package/src/__Tests__/FormTestBase.tsx +65 -64
- package/src/__Tests__/RealisticForm.test.tsx +82 -82
- package/src/__Tests__/StandardFormActions.test.tsx +17 -17
- package/src/__Tests__/SubmitFormButton.test.tsx +17 -17
- package/src/__Tests__/__snapshots__/StandardFormActions.test.tsx.snap +27 -27
- package/src/__Tests__/__snapshots__/SubmitFormButton.test.tsx.snap +20 -20
- package/src/__Tests__/index.ts +3 -3
- package/src/_variables.scss +11 -11
- package/src/index.ts +156 -153
- package/src/react-app-env.d.ts +1 -1
- package/src/setupTests.ts +1 -1
- package/src/utils/objectContainsNonSerializableProperty.test.tsx +49 -49
- package/src/utils/objectContainsNonSerializableProperty.ts +17 -17
- package/src/utils/objectToFormData.test.tsx +76 -76
- package/src/utils/objectToFormData.ts +105 -105
- package/src/utils/typeChecks.ts +18 -18
@@ -1,53 +1,50 @@
|
|
1
|
-
import React, { LegacyRef } from 'react';
|
2
|
-
import
|
3
|
-
import InputGroup, { InputGroupProps } from './InputGroup';
|
4
|
-
import { FormDefaults } from '../FormDefaults';
|
5
|
-
|
6
|
-
export interface StringInputGroupProps
|
7
|
-
extends Omit<
|
8
|
-
InputGroupProps<string | undefined | null>,
|
9
|
-
'onChange' | 'type' | 'value'
|
10
|
-
> {
|
11
|
-
type?:
|
12
|
-
| 'color'
|
13
|
-
| 'email'
|
14
|
-
| 'search'
|
15
|
-
| 'tel'
|
16
|
-
| 'text'
|
17
|
-
| 'url'
|
18
|
-
| 'password'
|
19
|
-
| 'textarea';
|
20
|
-
}
|
21
|
-
|
22
|
-
function StringInputGroup(
|
23
|
-
{ className, ...rest }: StringInputGroupProps,
|
24
|
-
ref: LegacyRef<HTMLInputElement>
|
25
|
-
) {
|
26
|
-
const { input } = rest;
|
27
|
-
|
28
|
-
return (
|
29
|
-
<InputGroup
|
30
|
-
ref={ref}
|
31
|
-
{...rest}
|
32
|
-
className={
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
) as React.ComponentType<StringInputGroupProps>;
|
52
|
-
|
53
|
-
export default StringInputGroupWithRef;
|
1
|
+
import React, { LegacyRef } from 'react';
|
2
|
+
import { clsx } from 'clsx';
|
3
|
+
import InputGroup, { InputGroupProps } from './InputGroup';
|
4
|
+
import { FormDefaults } from '../FormDefaults';
|
5
|
+
|
6
|
+
export interface StringInputGroupProps
|
7
|
+
extends Omit<
|
8
|
+
InputGroupProps<string | undefined | null>,
|
9
|
+
'onChange' | 'type' | 'value'
|
10
|
+
> {
|
11
|
+
type?:
|
12
|
+
| 'color'
|
13
|
+
| 'email'
|
14
|
+
| 'search'
|
15
|
+
| 'tel'
|
16
|
+
| 'text'
|
17
|
+
| 'url'
|
18
|
+
| 'password'
|
19
|
+
| 'textarea';
|
20
|
+
}
|
21
|
+
|
22
|
+
function StringInputGroup(
|
23
|
+
{ className, ...rest }: StringInputGroupProps,
|
24
|
+
ref: LegacyRef<HTMLInputElement>
|
25
|
+
) {
|
26
|
+
const { input } = rest;
|
27
|
+
|
28
|
+
return (
|
29
|
+
<InputGroup
|
30
|
+
ref={ref}
|
31
|
+
{...rest}
|
32
|
+
className={clsx(className, FormDefaults.cssClassPrefix + 'string-group')}
|
33
|
+
value={input.value ?? ''}
|
34
|
+
onChange={(e) => {
|
35
|
+
if (!e.target.value) {
|
36
|
+
input.onChange(undefined);
|
37
|
+
} else {
|
38
|
+
input.onChange(e.target.value);
|
39
|
+
}
|
40
|
+
}}
|
41
|
+
/>
|
42
|
+
);
|
43
|
+
}
|
44
|
+
|
45
|
+
/** Standard string input group. */
|
46
|
+
const StringInputGroupWithRef = React.forwardRef(
|
47
|
+
StringInputGroup
|
48
|
+
) as React.ComponentType<StringInputGroupProps>;
|
49
|
+
|
50
|
+
export default StringInputGroupWithRef;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { render } from '@testing-library/react';
|
2
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
3
|
+
import { CheckboxInputGroup } from 'index';
|
4
|
+
|
5
|
+
describe('CheckboxInputGroup', () => {
|
6
|
+
it('renders without crashing', () => {
|
7
|
+
render(
|
8
|
+
<FormTestBase>
|
9
|
+
{({ Field }) => (
|
10
|
+
<Field name="isMusicEnjoyer" Component={CheckboxInputGroup} />
|
11
|
+
)}
|
12
|
+
</FormTestBase>
|
13
|
+
);
|
14
|
+
});
|
15
|
+
|
16
|
+
it('has matching snapshot', () => {
|
17
|
+
const renderResult = render(
|
18
|
+
<FormTestBase>
|
19
|
+
{({ Field }) => (
|
20
|
+
<Field name="isMusicEnjoyer" Component={CheckboxInputGroup} />
|
21
|
+
)}
|
22
|
+
</FormTestBase>
|
23
|
+
);
|
24
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
25
|
+
});
|
26
|
+
});
|
@@ -1,35 +1,35 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
-
import IconInputGroup from '../IconInputGroup';
|
5
|
-
|
6
|
-
describe('IconInputGroup', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<Field
|
12
|
-
name="nameWithIcon"
|
13
|
-
Component={IconInputGroup}
|
14
|
-
icon={<span>Pretend this is an icon</span>}
|
15
|
-
/>
|
16
|
-
)}
|
17
|
-
</FormTestBase>
|
18
|
-
);
|
19
|
-
});
|
20
|
-
|
21
|
-
it('has matching snapshot', () => {
|
22
|
-
const renderResult = render(
|
23
|
-
<FormTestBase>
|
24
|
-
{({ Field }) => (
|
25
|
-
<Field
|
26
|
-
name="nameWithIcon"
|
27
|
-
Component={IconInputGroup}
|
28
|
-
icon={<span>Pretend this is an icon</span>}
|
29
|
-
/>
|
30
|
-
)}
|
31
|
-
</FormTestBase>
|
32
|
-
);
|
33
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
34
|
-
});
|
35
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
+
import IconInputGroup from '../IconInputGroup';
|
5
|
+
|
6
|
+
describe('IconInputGroup', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<Field
|
12
|
+
name="nameWithIcon"
|
13
|
+
Component={IconInputGroup}
|
14
|
+
icon={<span>Pretend this is an icon</span>}
|
15
|
+
/>
|
16
|
+
)}
|
17
|
+
</FormTestBase>
|
18
|
+
);
|
19
|
+
});
|
20
|
+
|
21
|
+
it('has matching snapshot', () => {
|
22
|
+
const renderResult = render(
|
23
|
+
<FormTestBase>
|
24
|
+
{({ Field }) => (
|
25
|
+
<Field
|
26
|
+
name="nameWithIcon"
|
27
|
+
Component={IconInputGroup}
|
28
|
+
icon={<span>Pretend this is an icon</span>}
|
29
|
+
/>
|
30
|
+
)}
|
31
|
+
</FormTestBase>
|
32
|
+
);
|
33
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
34
|
+
});
|
35
|
+
});
|
@@ -1,37 +1,37 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
-
import MoneyInputGroup from '../MoneyInputGroup';
|
5
|
-
|
6
|
-
describe('MoneyInputGroup', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<Field
|
12
|
-
name="yearlySalaryUSD"
|
13
|
-
Component={MoneyInputGroup}
|
14
|
-
label="Salary"
|
15
|
-
className="something-here"
|
16
|
-
/>
|
17
|
-
)}
|
18
|
-
</FormTestBase>
|
19
|
-
);
|
20
|
-
});
|
21
|
-
|
22
|
-
it('has matching snapshot', () => {
|
23
|
-
const renderResult = render(
|
24
|
-
<FormTestBase>
|
25
|
-
{({ Field }) => (
|
26
|
-
<Field
|
27
|
-
name="yearlySalaryUSD"
|
28
|
-
Component={MoneyInputGroup}
|
29
|
-
label="Salary"
|
30
|
-
className="something-here"
|
31
|
-
/>
|
32
|
-
)}
|
33
|
-
</FormTestBase>
|
34
|
-
);
|
35
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
36
|
-
});
|
37
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
+
import MoneyInputGroup from '../MoneyInputGroup';
|
5
|
+
|
6
|
+
describe('MoneyInputGroup', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<Field
|
12
|
+
name="yearlySalaryUSD"
|
13
|
+
Component={MoneyInputGroup}
|
14
|
+
label="Salary"
|
15
|
+
className="something-here"
|
16
|
+
/>
|
17
|
+
)}
|
18
|
+
</FormTestBase>
|
19
|
+
);
|
20
|
+
});
|
21
|
+
|
22
|
+
it('has matching snapshot', () => {
|
23
|
+
const renderResult = render(
|
24
|
+
<FormTestBase>
|
25
|
+
{({ Field }) => (
|
26
|
+
<Field
|
27
|
+
name="yearlySalaryUSD"
|
28
|
+
Component={MoneyInputGroup}
|
29
|
+
label="Salary"
|
30
|
+
className="something-here"
|
31
|
+
/>
|
32
|
+
)}
|
33
|
+
</FormTestBase>
|
34
|
+
);
|
35
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
36
|
+
});
|
37
|
+
});
|
@@ -1,35 +1,35 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
-
import NumberInputGroup from '../NumberInputGroup';
|
5
|
-
|
6
|
-
describe('NumberInputGroup', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<Field
|
12
|
-
name="numberOfArms"
|
13
|
-
Component={NumberInputGroup}
|
14
|
-
label="Arm Count"
|
15
|
-
/>
|
16
|
-
)}
|
17
|
-
</FormTestBase>
|
18
|
-
);
|
19
|
-
});
|
20
|
-
|
21
|
-
it('has matching snapshot', () => {
|
22
|
-
const renderResult = render(
|
23
|
-
<FormTestBase>
|
24
|
-
{({ Field }) => (
|
25
|
-
<Field
|
26
|
-
name="numberOfArms"
|
27
|
-
Component={NumberInputGroup}
|
28
|
-
label="Arm Count"
|
29
|
-
/>
|
30
|
-
)}
|
31
|
-
</FormTestBase>
|
32
|
-
);
|
33
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
34
|
-
});
|
35
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
+
import NumberInputGroup from '../NumberInputGroup';
|
5
|
+
|
6
|
+
describe('NumberInputGroup', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<Field
|
12
|
+
name="numberOfArms"
|
13
|
+
Component={NumberInputGroup}
|
14
|
+
label="Arm Count"
|
15
|
+
/>
|
16
|
+
)}
|
17
|
+
</FormTestBase>
|
18
|
+
);
|
19
|
+
});
|
20
|
+
|
21
|
+
it('has matching snapshot', () => {
|
22
|
+
const renderResult = render(
|
23
|
+
<FormTestBase>
|
24
|
+
{({ Field }) => (
|
25
|
+
<Field
|
26
|
+
name="numberOfArms"
|
27
|
+
Component={NumberInputGroup}
|
28
|
+
label="Arm Count"
|
29
|
+
/>
|
30
|
+
)}
|
31
|
+
</FormTestBase>
|
32
|
+
);
|
33
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
34
|
+
});
|
35
|
+
});
|
@@ -1,36 +1,36 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
-
import PhoneNumberInputGroup from '../PhoneNumberInputGroup';
|
5
|
-
|
6
|
-
describe('PhoneNumberInputGroup', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<Field
|
12
|
-
name="phoneNumber"
|
13
|
-
Component={PhoneNumberInputGroup}
|
14
|
-
label="Phone Number"
|
15
|
-
className="something-here"
|
16
|
-
/>
|
17
|
-
)}
|
18
|
-
</FormTestBase>
|
19
|
-
);
|
20
|
-
});
|
21
|
-
it('has matching snapshot', () => {
|
22
|
-
const renderResult = render(
|
23
|
-
<FormTestBase>
|
24
|
-
{({ Field }) => (
|
25
|
-
<Field
|
26
|
-
name="phoneNumber"
|
27
|
-
Component={PhoneNumberInputGroup}
|
28
|
-
label="Phone Number"
|
29
|
-
className="something-here"
|
30
|
-
/>
|
31
|
-
)}
|
32
|
-
</FormTestBase>
|
33
|
-
);
|
34
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
35
|
-
});
|
36
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
+
import PhoneNumberInputGroup from '../PhoneNumberInputGroup';
|
5
|
+
|
6
|
+
describe('PhoneNumberInputGroup', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<Field
|
12
|
+
name="phoneNumber"
|
13
|
+
Component={PhoneNumberInputGroup}
|
14
|
+
label="Phone Number"
|
15
|
+
className="something-here"
|
16
|
+
/>
|
17
|
+
)}
|
18
|
+
</FormTestBase>
|
19
|
+
);
|
20
|
+
});
|
21
|
+
it('has matching snapshot', () => {
|
22
|
+
const renderResult = render(
|
23
|
+
<FormTestBase>
|
24
|
+
{({ Field }) => (
|
25
|
+
<Field
|
26
|
+
name="phoneNumber"
|
27
|
+
Component={PhoneNumberInputGroup}
|
28
|
+
label="Phone Number"
|
29
|
+
className="something-here"
|
30
|
+
/>
|
31
|
+
)}
|
32
|
+
</FormTestBase>
|
33
|
+
);
|
34
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
35
|
+
});
|
36
|
+
});
|
@@ -1,27 +1,27 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
3
|
-
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
-
import StringInputGroup from '../StringInputGroup';
|
5
|
-
|
6
|
-
describe('StringInputGroup', () => {
|
7
|
-
it('renders without crashing', () => {
|
8
|
-
render(
|
9
|
-
<FormTestBase>
|
10
|
-
{({ Field }) => (
|
11
|
-
<Field name="name" Component={StringInputGroup} label="Name" />
|
12
|
-
)}
|
13
|
-
</FormTestBase>
|
14
|
-
);
|
15
|
-
});
|
16
|
-
|
17
|
-
it('has matching snapshot', () => {
|
18
|
-
const renderResult = render(
|
19
|
-
<FormTestBase>
|
20
|
-
{({ Field }) => (
|
21
|
-
<Field name="name" Component={StringInputGroup} label="Name" />
|
22
|
-
)}
|
23
|
-
</FormTestBase>
|
24
|
-
);
|
25
|
-
expect(renderResult.asFragment()).toMatchSnapshot();
|
26
|
-
});
|
27
|
-
});
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from '@testing-library/react';
|
3
|
+
import FormTestBase from '../../__Tests__/FormTestBase';
|
4
|
+
import StringInputGroup from '../StringInputGroup';
|
5
|
+
|
6
|
+
describe('StringInputGroup', () => {
|
7
|
+
it('renders without crashing', () => {
|
8
|
+
render(
|
9
|
+
<FormTestBase>
|
10
|
+
{({ Field }) => (
|
11
|
+
<Field name="name" Component={StringInputGroup} label="Name" />
|
12
|
+
)}
|
13
|
+
</FormTestBase>
|
14
|
+
);
|
15
|
+
});
|
16
|
+
|
17
|
+
it('has matching snapshot', () => {
|
18
|
+
const renderResult = render(
|
19
|
+
<FormTestBase>
|
20
|
+
{({ Field }) => (
|
21
|
+
<Field name="name" Component={StringInputGroup} label="Name" />
|
22
|
+
)}
|
23
|
+
</FormTestBase>
|
24
|
+
);
|
25
|
+
expect(renderResult.asFragment()).toMatchSnapshot();
|
26
|
+
});
|
27
|
+
});
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`CheckboxInputGroup has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
class="envoc-form-form"
|
8
|
+
>
|
9
|
+
<div
|
10
|
+
class="envoc-form-checkbox-group label-on-right envoc-form-group"
|
11
|
+
>
|
12
|
+
<div
|
13
|
+
id="ismusicenjoyer-error-scroll-target"
|
14
|
+
style="display: none;"
|
15
|
+
/>
|
16
|
+
<div
|
17
|
+
class="envoc-form-checkbox-group-input"
|
18
|
+
>
|
19
|
+
<input
|
20
|
+
aria-invalid="false"
|
21
|
+
class="envoc-form-checkbox-group"
|
22
|
+
id="isMusicEnjoyer"
|
23
|
+
name="isMusicEnjoyer"
|
24
|
+
type="checkbox"
|
25
|
+
/>
|
26
|
+
<label
|
27
|
+
for="isMusicEnjoyer"
|
28
|
+
/>
|
29
|
+
</div>
|
30
|
+
</div>
|
31
|
+
</form>
|
32
|
+
</DocumentFragment>
|
33
|
+
`;
|
@@ -1,32 +1,32 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`IconInputGroup has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
class="envoc-form-form"
|
8
|
-
>
|
9
|
-
<div
|
10
|
-
class="envoc-form-icon-input-group envoc-form-input-group envoc-form-group"
|
11
|
-
>
|
12
|
-
<div
|
13
|
-
id="namewithicon-error-scroll-target"
|
14
|
-
style="display: none;"
|
15
|
-
/>
|
16
|
-
<label
|
17
|
-
for="nameWithIcon"
|
18
|
-
/>
|
19
|
-
<span>
|
20
|
-
Pretend this is an icon
|
21
|
-
</span>
|
22
|
-
<input
|
23
|
-
aria-invalid="false"
|
24
|
-
class="envoc-form-icon-input-group envoc-form-input-group"
|
25
|
-
id="nameWithIcon"
|
26
|
-
name="nameWithIcon"
|
27
|
-
value=""
|
28
|
-
/>
|
29
|
-
</div>
|
30
|
-
</form>
|
31
|
-
</DocumentFragment>
|
32
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`IconInputGroup has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
class="envoc-form-form"
|
8
|
+
>
|
9
|
+
<div
|
10
|
+
class="envoc-form-icon-input-group envoc-form-input-group envoc-form-group"
|
11
|
+
>
|
12
|
+
<div
|
13
|
+
id="namewithicon-error-scroll-target"
|
14
|
+
style="display: none;"
|
15
|
+
/>
|
16
|
+
<label
|
17
|
+
for="nameWithIcon"
|
18
|
+
/>
|
19
|
+
<span>
|
20
|
+
Pretend this is an icon
|
21
|
+
</span>
|
22
|
+
<input
|
23
|
+
aria-invalid="false"
|
24
|
+
class="envoc-form-icon-input-group envoc-form-input-group"
|
25
|
+
id="nameWithIcon"
|
26
|
+
name="nameWithIcon"
|
27
|
+
value=""
|
28
|
+
/>
|
29
|
+
</div>
|
30
|
+
</form>
|
31
|
+
</DocumentFragment>
|
32
|
+
`;
|
@@ -1,34 +1,34 @@
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
-
|
3
|
-
exports[`MoneyInputGroup has matching snapshot 1`] = `
|
4
|
-
<DocumentFragment>
|
5
|
-
<form
|
6
|
-
action="#"
|
7
|
-
class="envoc-form-form"
|
8
|
-
>
|
9
|
-
<div
|
10
|
-
class="something-here envoc-form-money-group envoc-form-input-group envoc-form-group"
|
11
|
-
>
|
12
|
-
<div
|
13
|
-
id="yearlysalaryusd-error-scroll-target"
|
14
|
-
style="display: none;"
|
15
|
-
/>
|
16
|
-
<label
|
17
|
-
for="yearlySalaryUSD"
|
18
|
-
>
|
19
|
-
Salary
|
20
|
-
</label>
|
21
|
-
<input
|
22
|
-
aria-invalid="false"
|
23
|
-
class="something-here envoc-form-money-group envoc-form-input-group"
|
24
|
-
id="yearlySalaryUSD"
|
25
|
-
min="0"
|
26
|
-
name="yearlySalaryUSD"
|
27
|
-
step="0.01"
|
28
|
-
type="number"
|
29
|
-
value=""
|
30
|
-
/>
|
31
|
-
</div>
|
32
|
-
</form>
|
33
|
-
</DocumentFragment>
|
34
|
-
`;
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`MoneyInputGroup has matching snapshot 1`] = `
|
4
|
+
<DocumentFragment>
|
5
|
+
<form
|
6
|
+
action="#"
|
7
|
+
class="envoc-form-form"
|
8
|
+
>
|
9
|
+
<div
|
10
|
+
class="something-here envoc-form-money-group envoc-form-input-group envoc-form-group"
|
11
|
+
>
|
12
|
+
<div
|
13
|
+
id="yearlysalaryusd-error-scroll-target"
|
14
|
+
style="display: none;"
|
15
|
+
/>
|
16
|
+
<label
|
17
|
+
for="yearlySalaryUSD"
|
18
|
+
>
|
19
|
+
Salary
|
20
|
+
</label>
|
21
|
+
<input
|
22
|
+
aria-invalid="false"
|
23
|
+
class="something-here envoc-form-money-group envoc-form-input-group"
|
24
|
+
id="yearlySalaryUSD"
|
25
|
+
min="0"
|
26
|
+
name="yearlySalaryUSD"
|
27
|
+
step="0.01"
|
28
|
+
type="number"
|
29
|
+
value=""
|
30
|
+
/>
|
31
|
+
</div>
|
32
|
+
</form>
|
33
|
+
</DocumentFragment>
|
34
|
+
`;
|