@inseefr/lunatic 0.3.4-experimental → 0.3.7-experimental
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/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/breadcrumb/component.js +29 -29
- package/src/components/button/component.js +53 -53
- package/src/components/button/index.js +1 -1
- package/src/components/checkbox/index.js +3 -3
- package/src/components/datepicker/index.js +1 -1
- package/src/components/declarations/index.js +1 -1
- package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
- package/src/components/filter-description/component.js +42 -42
- package/src/components/icon/component.js +33 -33
- package/src/components/index.js +2 -0
- package/src/components/input/index.js +2 -2
- package/src/components/loop/index.js +1 -1
- package/src/components/loop-constructor/wrapper/body-component.js +13 -1
- package/src/components/radio/index.js +1 -1
- package/src/components/sequence/index.js +1 -1
- package/src/components/subsequence/index.js +1 -1
- package/src/components/suggester/check-store.js +70 -70
- package/src/components/suggester/components/create-on-keydown-callback.js +28 -28
- package/src/components/tooltip/response.js +52 -52
- package/src/stories/checkbox-boolean/data-forced.json +48 -48
- package/src/stories/checkbox-group/data-vtl.json +102 -102
- package/src/stories/icons/icons.stories.js +16 -16
- package/src/stories/questionnaire/kish.json +275 -0
- package/src/stories/questionnaire/questionnaire.stories.js +12 -0
- package/src/stories/utils/custom-lunatic.scss +23 -23
- package/src/tests/components/breadcrumb.spec.js +13 -13
- package/src/tests/components/button.spec.js +11 -11
- package/src/tests/components/checkbox-boolean.spec.js +45 -45
- package/src/tests/components/checkbox-group.spec.js +53 -53
- package/src/tests/components/checkbox-one.spec.js +32 -32
- package/src/tests/components/datepicker.spec.js +22 -22
- package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
- package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
- package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
- package/src/tests/components/declarations.spec.js +46 -46
- package/src/tests/components/input.spec.js +18 -18
- package/src/tests/components/loops/loop-static.json +66 -66
- package/src/tests/components/loops/loop.json +258 -258
- package/src/tests/components/loops/loop.spec.js +30 -30
- package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
- package/src/tests/components/progress-bar.spec.js +15 -15
- package/src/tests/components/radio.spec.js +27 -27
- package/src/tests/components/sequence.spec.js +9 -9
- package/src/tests/components/subsequence.spec.js +9 -9
- package/src/tests/components/table.spec.js +11 -11
- package/src/tests/components/textarea.spec.js +18 -18
- package/src/tests/components/tooltip.spec.js +25 -25
- package/src/tests/setup/setupTests.js +4 -4
- package/src/tests/utils/lib/alphabet.spec.js +36 -36
- package/src/tests/utils/lib/array.spec.js +22 -22
- package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
- package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
- package/src/tests/utils/lib/input-number.spec.js +18 -18
- package/src/tests/utils/lib/items-positioning.spec.js +17 -17
- package/src/tests/utils/lib/label-position.spec.js +22 -22
- package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
- package/src/tests/utils/lib/loops/shared.spec.js +82 -82
- package/src/tests/utils/lib/missing/missing.spec.js +74 -74
- package/src/tests/utils/lib/missing/mock.js +137 -137
- package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
- package/src/tests/utils/lib/responses.spec.js +64 -64
- package/src/tests/utils/lib/style.spec.js +26 -26
- package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
- package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
- package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
- package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
- package/src/tests/utils/to-expose/handler/results/index.js +6 -6
- package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
- package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
- package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
- package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
- package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
- package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
- package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
- package/src/tests/utils/to-expose/state/results.js +78 -78
- package/src/utils/lib/tooltip/build-response.js +41 -41
- package/src/utils/store-tools/create/index.js +1 -1
- package/src/utils/store-tools/create/update-store-info.js +26 -26
- package/src/utils/store-tools/index.js +5 -5
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
-
import { CheckboxBoolean } from 'components';
|
|
5
|
-
|
|
6
|
-
describe('checkbox-boolean', () => {
|
|
7
|
-
const handleChange = jest.fn();
|
|
8
|
-
const defaultProps = { id: 'id', label: '', handleChange };
|
|
9
|
-
|
|
10
|
-
it('renders without crashing', () => {
|
|
11
|
-
shallow(<CheckboxBoolean {...defaultProps} />);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('returns management component', () => {
|
|
15
|
-
shallow(<CheckboxBoolean {...defaultProps} label="label" management />);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('returns disabled component', () => {
|
|
19
|
-
shallow(<CheckboxBoolean {...defaultProps} label="label" disabled />);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('renders firing useEffect', () => {
|
|
23
|
-
const wrapper = mount(<CheckboxBoolean {...defaultProps} />);
|
|
24
|
-
wrapper.setProps({ focused: true });
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('test VERTICAL positioning', () => {
|
|
28
|
-
shallow(<CheckboxBoolean {...defaultProps} positioning="VERTICAL" />);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should trigger the change event', () => {
|
|
32
|
-
fakeSchedulers((advance) => {
|
|
33
|
-
const wrapper = shallow(<CheckboxBoolean {...defaultProps} />);
|
|
34
|
-
wrapper.find('input').simulate('change', {
|
|
35
|
-
target: {
|
|
36
|
-
checked: true,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
advance(400);
|
|
40
|
-
wrapper.update();
|
|
41
|
-
expect(handleChange).toHaveBeenCalled();
|
|
42
|
-
expect(handleChange).toHaveBeenCalledWith({ '': true });
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
+
import { CheckboxBoolean } from 'components';
|
|
5
|
+
|
|
6
|
+
describe('checkbox-boolean', () => {
|
|
7
|
+
const handleChange = jest.fn();
|
|
8
|
+
const defaultProps = { id: 'id', label: '', handleChange };
|
|
9
|
+
|
|
10
|
+
it('renders without crashing', () => {
|
|
11
|
+
shallow(<CheckboxBoolean {...defaultProps} />);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns management component', () => {
|
|
15
|
+
shallow(<CheckboxBoolean {...defaultProps} label="label" management />);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('returns disabled component', () => {
|
|
19
|
+
shallow(<CheckboxBoolean {...defaultProps} label="label" disabled />);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders firing useEffect', () => {
|
|
23
|
+
const wrapper = mount(<CheckboxBoolean {...defaultProps} />);
|
|
24
|
+
wrapper.setProps({ focused: true });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('test VERTICAL positioning', () => {
|
|
28
|
+
shallow(<CheckboxBoolean {...defaultProps} positioning="VERTICAL" />);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should trigger the change event', () => {
|
|
32
|
+
fakeSchedulers((advance) => {
|
|
33
|
+
const wrapper = shallow(<CheckboxBoolean {...defaultProps} />);
|
|
34
|
+
wrapper.find('input').simulate('change', {
|
|
35
|
+
target: {
|
|
36
|
+
checked: true,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
advance(400);
|
|
40
|
+
wrapper.update();
|
|
41
|
+
expect(handleChange).toHaveBeenCalled();
|
|
42
|
+
expect(handleChange).toHaveBeenCalledWith({ '': true });
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
-
import { CheckboxGroup } from 'components';
|
|
5
|
-
|
|
6
|
-
describe('checkbox-group', () => {
|
|
7
|
-
const handleChange = jest.fn();
|
|
8
|
-
const responses = [
|
|
9
|
-
{
|
|
10
|
-
id: '1',
|
|
11
|
-
response: { name: 'a', values: { COLLECTED: true } },
|
|
12
|
-
label: 'France',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: '2',
|
|
16
|
-
response: { name: 'b', values: { COLLECTED: false } },
|
|
17
|
-
label: 'Italy',
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
const defaultProps = { id: 'id', handleChange, responses };
|
|
21
|
-
|
|
22
|
-
it('returns management component', () => {
|
|
23
|
-
shallow(<CheckboxGroup {...defaultProps} management />);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('returns disabled component', () => {
|
|
27
|
-
shallow(<CheckboxGroup {...defaultProps} label="label" disabled />);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('renders firing useEffect', () => {
|
|
31
|
-
const wrapper = mount(<CheckboxGroup {...defaultProps} />);
|
|
32
|
-
wrapper.setProps({ focused: true });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should trigger the change event', () => {
|
|
36
|
-
fakeSchedulers((advance) => {
|
|
37
|
-
const wrapper = shallow(<CheckboxGroup {...defaultProps} />);
|
|
38
|
-
wrapper
|
|
39
|
-
.find('input')
|
|
40
|
-
.first()
|
|
41
|
-
.simulate('change', {
|
|
42
|
-
target: {
|
|
43
|
-
checked: false,
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
advance(400);
|
|
47
|
-
wrapper.update();
|
|
48
|
-
expect(handleChange).toHaveBeenCalled();
|
|
49
|
-
/*Cause specificHandler*/
|
|
50
|
-
expect(handleChange).toHaveBeenCalledWith({ a: null });
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
+
import { CheckboxGroup } from 'components';
|
|
5
|
+
|
|
6
|
+
describe('checkbox-group', () => {
|
|
7
|
+
const handleChange = jest.fn();
|
|
8
|
+
const responses = [
|
|
9
|
+
{
|
|
10
|
+
id: '1',
|
|
11
|
+
response: { name: 'a', values: { COLLECTED: true } },
|
|
12
|
+
label: 'France',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '2',
|
|
16
|
+
response: { name: 'b', values: { COLLECTED: false } },
|
|
17
|
+
label: 'Italy',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const defaultProps = { id: 'id', handleChange, responses };
|
|
21
|
+
|
|
22
|
+
it('returns management component', () => {
|
|
23
|
+
shallow(<CheckboxGroup {...defaultProps} management />);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('returns disabled component', () => {
|
|
27
|
+
shallow(<CheckboxGroup {...defaultProps} label="label" disabled />);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders firing useEffect', () => {
|
|
31
|
+
const wrapper = mount(<CheckboxGroup {...defaultProps} />);
|
|
32
|
+
wrapper.setProps({ focused: true });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should trigger the change event', () => {
|
|
36
|
+
fakeSchedulers((advance) => {
|
|
37
|
+
const wrapper = shallow(<CheckboxGroup {...defaultProps} />);
|
|
38
|
+
wrapper
|
|
39
|
+
.find('input')
|
|
40
|
+
.first()
|
|
41
|
+
.simulate('change', {
|
|
42
|
+
target: {
|
|
43
|
+
checked: false,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
advance(400);
|
|
47
|
+
wrapper.update();
|
|
48
|
+
expect(handleChange).toHaveBeenCalled();
|
|
49
|
+
/*Cause specificHandler*/
|
|
50
|
+
expect(handleChange).toHaveBeenCalledWith({ a: null });
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import { CheckboxOne } from 'components';
|
|
4
|
-
|
|
5
|
-
const handleChange = jest.fn();
|
|
6
|
-
const options = [
|
|
7
|
-
{ value: 'france', label: 'France' },
|
|
8
|
-
{ value: 'italy', label: 'Italy' },
|
|
9
|
-
];
|
|
10
|
-
const response = { values: { COLLECTED: 'italy' } };
|
|
11
|
-
|
|
12
|
-
const defaultProps = {
|
|
13
|
-
id: 'id',
|
|
14
|
-
label: 'label',
|
|
15
|
-
handleChange,
|
|
16
|
-
options,
|
|
17
|
-
response,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
describe('checkbox-one', () => {
|
|
21
|
-
it('renders without crashing', () => {
|
|
22
|
-
mount(<CheckboxOne {...defaultProps} />);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns management component', () => {
|
|
26
|
-
shallow(<CheckboxOne {...defaultProps} management />);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('returns disabled component', () => {
|
|
30
|
-
shallow(<CheckboxOne {...defaultProps} label="label" disabled />);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import { CheckboxOne } from 'components';
|
|
4
|
+
|
|
5
|
+
const handleChange = jest.fn();
|
|
6
|
+
const options = [
|
|
7
|
+
{ value: 'france', label: 'France' },
|
|
8
|
+
{ value: 'italy', label: 'Italy' },
|
|
9
|
+
];
|
|
10
|
+
const response = { values: { COLLECTED: 'italy' } };
|
|
11
|
+
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
id: 'id',
|
|
14
|
+
label: 'label',
|
|
15
|
+
handleChange,
|
|
16
|
+
options,
|
|
17
|
+
response,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('checkbox-one', () => {
|
|
21
|
+
it('renders without crashing', () => {
|
|
22
|
+
mount(<CheckboxOne {...defaultProps} />);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('returns management component', () => {
|
|
26
|
+
shallow(<CheckboxOne {...defaultProps} management />);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns disabled component', () => {
|
|
30
|
+
shallow(<CheckboxOne {...defaultProps} label="label" disabled />);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { Datepicker } from 'components';
|
|
4
|
-
|
|
5
|
-
const handleChange = jest.fn();
|
|
6
|
-
const defaultProps = {
|
|
7
|
-
id: 'id',
|
|
8
|
-
label: 'label',
|
|
9
|
-
handleChange,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
describe('datepicker', () => {
|
|
13
|
-
it('renders without crashing', () => {
|
|
14
|
-
shallow(<Datepicker {...defaultProps} />);
|
|
15
|
-
});
|
|
16
|
-
it('returns management component', () => {
|
|
17
|
-
shallow(<Datepicker {...defaultProps} label="label" management />);
|
|
18
|
-
});
|
|
19
|
-
it('returns disabled & readOnly component', () => {
|
|
20
|
-
shallow(<Datepicker {...defaultProps} label="label" disabled readOnly />);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { Datepicker } from 'components';
|
|
4
|
+
|
|
5
|
+
const handleChange = jest.fn();
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
id: 'id',
|
|
8
|
+
label: 'label',
|
|
9
|
+
handleChange,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('datepicker', () => {
|
|
13
|
+
it('renders without crashing', () => {
|
|
14
|
+
shallow(<Datepicker {...defaultProps} />);
|
|
15
|
+
});
|
|
16
|
+
it('returns management component', () => {
|
|
17
|
+
shallow(<Datepicker {...defaultProps} label="label" management />);
|
|
18
|
+
});
|
|
19
|
+
it('returns disabled & readOnly component', () => {
|
|
20
|
+
shallow(<Datepicker {...defaultProps} label="label" disabled readOnly />);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import { InputDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
4
|
-
|
|
5
|
-
const handleChange = jest.fn();
|
|
6
|
-
|
|
7
|
-
const response = { values: { COLLECTED: 'xxx' } };
|
|
8
|
-
|
|
9
|
-
const defaultProps = {
|
|
10
|
-
id: 'id',
|
|
11
|
-
label: 'label',
|
|
12
|
-
handleChange,
|
|
13
|
-
type: 'text',
|
|
14
|
-
roleType: 'input',
|
|
15
|
-
response,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
describe('input-declarations-wrapper', () => {
|
|
19
|
-
it('renders without crashing', () => {
|
|
20
|
-
shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
21
|
-
shallow(
|
|
22
|
-
<InputDeclarationsWrapper
|
|
23
|
-
{...defaultProps}
|
|
24
|
-
type={null}
|
|
25
|
-
roleType="textarea"
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
it('returns readOnly and autoComplete component', () => {
|
|
30
|
-
const wrapper = shallow(
|
|
31
|
-
<InputDeclarationsWrapper {...defaultProps} readOnly autoComplete />
|
|
32
|
-
);
|
|
33
|
-
expect(wrapper.find('input').prop('readOnly')).toBeTruthy();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('returns enabled component', () => {
|
|
37
|
-
const wrapper = shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
38
|
-
expect(wrapper.find('input').prop('readOnly')).toBeFalsy();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('returns mandatory component', () => {
|
|
42
|
-
const wrapper = shallow(
|
|
43
|
-
<InputDeclarationsWrapper {...defaultProps} mandatory />
|
|
44
|
-
);
|
|
45
|
-
expect(wrapper.find('input').prop('required')).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('returns management component', () => {
|
|
49
|
-
shallow(<InputDeclarationsWrapper {...defaultProps} management />);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('renders firing useEffect', () => {
|
|
53
|
-
const wrapper = mount(<InputDeclarationsWrapper {...defaultProps} />);
|
|
54
|
-
wrapper.setProps({ focused: true });
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// it('should trigger the change event', () => {
|
|
58
|
-
// const wrapper = shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
59
|
-
// wrapper.find('input').simulate('change', {
|
|
60
|
-
// target: {
|
|
61
|
-
// value: 'new value',
|
|
62
|
-
// },
|
|
63
|
-
// });
|
|
64
|
-
// expect(handleChange).toHaveBeenCalled();
|
|
65
|
-
// expect(handleChange).toHaveBeenCalledWith({ '': 'new value' });
|
|
66
|
-
// });
|
|
67
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import { InputDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
4
|
+
|
|
5
|
+
const handleChange = jest.fn();
|
|
6
|
+
|
|
7
|
+
const response = { values: { COLLECTED: 'xxx' } };
|
|
8
|
+
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
id: 'id',
|
|
11
|
+
label: 'label',
|
|
12
|
+
handleChange,
|
|
13
|
+
type: 'text',
|
|
14
|
+
roleType: 'input',
|
|
15
|
+
response,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('input-declarations-wrapper', () => {
|
|
19
|
+
it('renders without crashing', () => {
|
|
20
|
+
shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
21
|
+
shallow(
|
|
22
|
+
<InputDeclarationsWrapper
|
|
23
|
+
{...defaultProps}
|
|
24
|
+
type={null}
|
|
25
|
+
roleType="textarea"
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
it('returns readOnly and autoComplete component', () => {
|
|
30
|
+
const wrapper = shallow(
|
|
31
|
+
<InputDeclarationsWrapper {...defaultProps} readOnly autoComplete />
|
|
32
|
+
);
|
|
33
|
+
expect(wrapper.find('input').prop('readOnly')).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns enabled component', () => {
|
|
37
|
+
const wrapper = shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
38
|
+
expect(wrapper.find('input').prop('readOnly')).toBeFalsy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('returns mandatory component', () => {
|
|
42
|
+
const wrapper = shallow(
|
|
43
|
+
<InputDeclarationsWrapper {...defaultProps} mandatory />
|
|
44
|
+
);
|
|
45
|
+
expect(wrapper.find('input').prop('required')).toBeTruthy();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns management component', () => {
|
|
49
|
+
shallow(<InputDeclarationsWrapper {...defaultProps} management />);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders firing useEffect', () => {
|
|
53
|
+
const wrapper = mount(<InputDeclarationsWrapper {...defaultProps} />);
|
|
54
|
+
wrapper.setProps({ focused: true });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// it('should trigger the change event', () => {
|
|
58
|
+
// const wrapper = shallow(<InputDeclarationsWrapper {...defaultProps} />);
|
|
59
|
+
// wrapper.find('input').simulate('change', {
|
|
60
|
+
// target: {
|
|
61
|
+
// value: 'new value',
|
|
62
|
+
// },
|
|
63
|
+
// });
|
|
64
|
+
// expect(handleChange).toHaveBeenCalled();
|
|
65
|
+
// expect(handleChange).toHaveBeenCalledWith({ '': 'new value' });
|
|
66
|
+
// });
|
|
67
|
+
});
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow, mount } from 'enzyme';
|
|
3
|
-
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
-
import { ListDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
5
|
-
|
|
6
|
-
const handleChange = jest.fn();
|
|
7
|
-
const options = [
|
|
8
|
-
{ value: 'france', label: 'France' },
|
|
9
|
-
{ value: 'italy', label: 'Italy' },
|
|
10
|
-
];
|
|
11
|
-
const response = { values: { COLLECTED: 'italy' } };
|
|
12
|
-
|
|
13
|
-
const defaultProps = {
|
|
14
|
-
id: 'id',
|
|
15
|
-
label: 'label',
|
|
16
|
-
handleChange,
|
|
17
|
-
options,
|
|
18
|
-
response,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe('list-declarations-wrapper', () => {
|
|
22
|
-
it('renders without crashing', () => {
|
|
23
|
-
mount(<ListDeclarationsWrapper {...defaultProps} type="radio" />);
|
|
24
|
-
mount(<ListDeclarationsWrapper {...defaultProps} type="checkbox" />);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('returns management component', () => {
|
|
28
|
-
shallow(
|
|
29
|
-
<ListDeclarationsWrapper {...defaultProps} management type="radio" />
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('renders firing useEffect', () => {
|
|
34
|
-
const wrapper = mount(
|
|
35
|
-
<ListDeclarationsWrapper {...defaultProps} type="radio" />
|
|
36
|
-
);
|
|
37
|
-
wrapper.setProps({ focused: true });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should trigger the change event', () => {
|
|
41
|
-
fakeSchedulers((advance) => {
|
|
42
|
-
const wrapper = shallow(
|
|
43
|
-
<ListDeclarationsWrapper {...defaultProps} type="radio" />
|
|
44
|
-
);
|
|
45
|
-
wrapper.find('input').first().simulate('change');
|
|
46
|
-
advance(400);
|
|
47
|
-
wrapper.update();
|
|
48
|
-
expect(handleChange).toHaveBeenCalled();
|
|
49
|
-
expect(handleChange).toHaveBeenCalledWith({ '': 'france' });
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow, mount } from 'enzyme';
|
|
3
|
+
import { fakeSchedulers } from 'rxjs-marbles/jest';
|
|
4
|
+
import { ListDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
5
|
+
|
|
6
|
+
const handleChange = jest.fn();
|
|
7
|
+
const options = [
|
|
8
|
+
{ value: 'france', label: 'France' },
|
|
9
|
+
{ value: 'italy', label: 'Italy' },
|
|
10
|
+
];
|
|
11
|
+
const response = { values: { COLLECTED: 'italy' } };
|
|
12
|
+
|
|
13
|
+
const defaultProps = {
|
|
14
|
+
id: 'id',
|
|
15
|
+
label: 'label',
|
|
16
|
+
handleChange,
|
|
17
|
+
options,
|
|
18
|
+
response,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe('list-declarations-wrapper', () => {
|
|
22
|
+
it('renders without crashing', () => {
|
|
23
|
+
mount(<ListDeclarationsWrapper {...defaultProps} type="radio" />);
|
|
24
|
+
mount(<ListDeclarationsWrapper {...defaultProps} type="checkbox" />);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('returns management component', () => {
|
|
28
|
+
shallow(
|
|
29
|
+
<ListDeclarationsWrapper {...defaultProps} management type="radio" />
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders firing useEffect', () => {
|
|
34
|
+
const wrapper = mount(
|
|
35
|
+
<ListDeclarationsWrapper {...defaultProps} type="radio" />
|
|
36
|
+
);
|
|
37
|
+
wrapper.setProps({ focused: true });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should trigger the change event', () => {
|
|
41
|
+
fakeSchedulers((advance) => {
|
|
42
|
+
const wrapper = shallow(
|
|
43
|
+
<ListDeclarationsWrapper {...defaultProps} type="radio" />
|
|
44
|
+
);
|
|
45
|
+
wrapper.find('input').first().simulate('change');
|
|
46
|
+
advance(400);
|
|
47
|
+
wrapper.update();
|
|
48
|
+
expect(handleChange).toHaveBeenCalled();
|
|
49
|
+
expect(handleChange).toHaveBeenCalledWith({ '': 'france' });
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { SimpleDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
4
|
-
|
|
5
|
-
describe('simple-declarations-wrapper', () => {
|
|
6
|
-
it('renders without crashing', () => {
|
|
7
|
-
shallow(
|
|
8
|
-
<SimpleDeclarationsWrapper id="module-id" label="Sequence">
|
|
9
|
-
<span>{`test`}</span>
|
|
10
|
-
</SimpleDeclarationsWrapper>
|
|
11
|
-
);
|
|
12
|
-
});
|
|
13
|
-
it('renders with elements', () => {
|
|
14
|
-
const wrapper = shallow(
|
|
15
|
-
<SimpleDeclarationsWrapper id="module-id" label="Sequence">
|
|
16
|
-
<span>{`test`}</span>
|
|
17
|
-
</SimpleDeclarationsWrapper>
|
|
18
|
-
);
|
|
19
|
-
expect(wrapper.children()).toHaveLength(4);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { SimpleDeclarationsWrapper } from 'components/declarations/wrappers';
|
|
4
|
+
|
|
5
|
+
describe('simple-declarations-wrapper', () => {
|
|
6
|
+
it('renders without crashing', () => {
|
|
7
|
+
shallow(
|
|
8
|
+
<SimpleDeclarationsWrapper id="module-id" label="Sequence">
|
|
9
|
+
<span>{`test`}</span>
|
|
10
|
+
</SimpleDeclarationsWrapper>
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
it('renders with elements', () => {
|
|
14
|
+
const wrapper = shallow(
|
|
15
|
+
<SimpleDeclarationsWrapper id="module-id" label="Sequence">
|
|
16
|
+
<span>{`test`}</span>
|
|
17
|
+
</SimpleDeclarationsWrapper>
|
|
18
|
+
);
|
|
19
|
+
expect(wrapper.children()).toHaveLength(4);
|
|
20
|
+
});
|
|
21
|
+
});
|