@inseefr/lunatic 0.3.5-experimental → 0.3.8-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.
Files changed (98) hide show
  1. package/lib/index.js +6 -6
  2. package/lib/index.js.map +1 -1
  3. package/package.json +4 -3
  4. package/src/components/breadcrumb/component.js +29 -29
  5. package/src/components/button/component.js +53 -53
  6. package/src/components/button/index.js +1 -1
  7. package/src/components/checkbox/index.js +3 -3
  8. package/src/components/datepicker/index.js +1 -1
  9. package/src/components/declarations/index.js +1 -1
  10. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
  11. package/src/components/filter-description/component.js +42 -42
  12. package/src/components/icon/component.js +33 -33
  13. package/src/components/index.js +5 -3
  14. package/src/components/input/index.js +2 -2
  15. package/src/components/loop/index.js +1 -1
  16. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  17. package/src/components/radio/index.js +1 -1
  18. package/src/components/sequence/index.js +1 -1
  19. package/src/components/subsequence/index.js +1 -1
  20. package/src/components/suggester/check-store.js +70 -70
  21. package/src/components/suggester/components/create-on-keydown-callback.js +28 -28
  22. package/src/components/tooltip/response.js +52 -52
  23. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  24. package/src/stories/checkbox-group/data-vtl.json +102 -102
  25. package/src/stories/icons/icons.stories.js +16 -16
  26. package/src/stories/questionnaire/kish.json +275 -0
  27. package/src/stories/questionnaire/loop-and-controls.json +481 -0
  28. package/src/stories/questionnaire/questionnaire.stories.js +31 -0
  29. package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
  30. package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
  31. package/src/stories/suggester/data.json +31 -1
  32. package/src/stories/suggester/suggester-workers.stories.js +44 -0
  33. package/src/stories/suggester/suggester.stories.js +5 -0
  34. package/src/stories/utils/custom-lunatic.scss +23 -23
  35. package/src/tests/components/breadcrumb.spec.js +13 -13
  36. package/src/tests/components/button.spec.js +11 -11
  37. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  38. package/src/tests/components/checkbox-group.spec.js +53 -53
  39. package/src/tests/components/checkbox-one.spec.js +32 -32
  40. package/src/tests/components/datepicker.spec.js +22 -22
  41. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  42. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  43. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  44. package/src/tests/components/declarations.spec.js +46 -46
  45. package/src/tests/components/input.spec.js +18 -18
  46. package/src/tests/components/loops/loop-static.json +66 -66
  47. package/src/tests/components/loops/loop.json +258 -258
  48. package/src/tests/components/loops/loop.spec.js +30 -30
  49. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  50. package/src/tests/components/progress-bar.spec.js +15 -15
  51. package/src/tests/components/radio.spec.js +27 -27
  52. package/src/tests/components/sequence.spec.js +9 -9
  53. package/src/tests/components/subsequence.spec.js +9 -9
  54. package/src/tests/components/table.spec.js +11 -11
  55. package/src/tests/components/textarea.spec.js +18 -18
  56. package/src/tests/components/tooltip.spec.js +25 -25
  57. package/src/tests/setup/setupTests.js +4 -4
  58. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  59. package/src/tests/utils/lib/array.spec.js +22 -22
  60. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  61. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  62. package/src/tests/utils/lib/input-number.spec.js +18 -18
  63. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  64. package/src/tests/utils/lib/label-position.spec.js +22 -22
  65. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  66. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  67. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  68. package/src/tests/utils/lib/missing/mock.js +137 -137
  69. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  70. package/src/tests/utils/lib/responses.spec.js +64 -64
  71. package/src/tests/utils/lib/style.spec.js +26 -26
  72. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  73. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  74. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  75. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  76. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  77. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  78. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  79. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  80. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  81. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  82. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  83. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  84. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  85. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  86. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  87. package/src/tests/utils/to-expose/state/results.js +78 -78
  88. package/src/utils/lib/controls/utils.js +8 -2
  89. package/src/utils/lib/tooltip/build-response.js +41 -41
  90. package/src/utils/store-tools/create/index.js +1 -1
  91. package/src/utils/store-tools/create/update-store-info.js +26 -26
  92. package/src/utils/store-tools/index.js +5 -5
  93. package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +5 -1
  94. package/src/utils/suggester-workers/commons-tokenizer/index.js +1 -0
  95. package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +7 -1
  96. package/src/utils/to-expose/handler.js +12 -14
  97. package/src/utils/to-expose/hooks/lunatic-split.js +5 -2
  98. package/src/utils/to-expose/hooks/lunatic.js +5 -2
@@ -1,23 +1,23 @@
1
- * {
2
- box-sizing: border-box;
3
- --color-primary-dark: #2a5885;
4
- --color-primary-light: #5181b8;
5
- --color-primary-main: #4a73a4;
6
- --color-primary-contrast-text: #ffffff;
7
-
8
- --color-secondary-dark: #14202d;
9
- --color-secondary-light: #f7f8fa;
10
- --color-secondary-main: #1a293b;
11
- --color-secondary-contrast-text: #ffffff;
12
-
13
- --color-very-light: #dbe4ef;
14
- --color-very-very-light: #e6eaee;
15
- --color-current-item: #0d823e;
16
-
17
- --color-error: #f50c0c;
18
- --color-disabled: rgb(235, 235, 228);
19
- }
20
-
21
- .pagination {
22
- margin-top: 2em;
23
- }
1
+ * {
2
+ box-sizing: border-box;
3
+ --color-primary-dark: #2a5885;
4
+ --color-primary-light: #5181b8;
5
+ --color-primary-main: #4a73a4;
6
+ --color-primary-contrast-text: #ffffff;
7
+
8
+ --color-secondary-dark: #14202d;
9
+ --color-secondary-light: #f7f8fa;
10
+ --color-secondary-main: #1a293b;
11
+ --color-secondary-contrast-text: #ffffff;
12
+
13
+ --color-very-light: #dbe4ef;
14
+ --color-very-very-light: #e6eaee;
15
+ --color-current-item: #0d823e;
16
+
17
+ --color-error: #f50c0c;
18
+ --color-disabled: rgb(235, 235, 228);
19
+ }
20
+
21
+ .pagination {
22
+ margin-top: 2em;
23
+ }
@@ -1,13 +1,13 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import { Breadcrumb } from 'components';
4
-
5
- describe('breadcrumb', () => {
6
- it('renders without crashing', () => {
7
- shallow(<Breadcrumb elements={[]} />);
8
- });
9
- it('renders with elements', () => {
10
- const wrapper = shallow(<Breadcrumb elements={['One', 'Two']} />);
11
- expect(wrapper.find('.breadcrumb-lunatic').children()).toHaveLength(2);
12
- });
13
- });
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { Breadcrumb } from 'components';
4
+
5
+ describe('breadcrumb', () => {
6
+ it('renders without crashing', () => {
7
+ shallow(<Breadcrumb elements={[]} />);
8
+ });
9
+ it('renders with elements', () => {
10
+ const wrapper = shallow(<Breadcrumb elements={['One', 'Two']} />);
11
+ expect(wrapper.find('.breadcrumb-lunatic').children()).toHaveLength(2);
12
+ });
13
+ });
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import { Button } from 'components';
4
-
5
- describe('button', () => {
6
- const onClick = jest.fn();
7
-
8
- it('renders without crashing', () => {
9
- shallow(<Button value="Button" onClick={onClick} />);
10
- });
11
- });
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { Button } from 'components';
4
+
5
+ describe('button', () => {
6
+ const onClick = jest.fn();
7
+
8
+ it('renders without crashing', () => {
9
+ shallow(<Button value="Button" onClick={onClick} />);
10
+ });
11
+ });
@@ -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
+ });