@inseefr/lunatic 0.3.2-experimental → 0.3.6-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 (101) hide show
  1. package/lib/index.js +38 -82
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -2
  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/input-declarations-wrapper.js +28 -7
  11. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
  12. package/src/components/dropdown/commons/components/dropdown.js +21 -0
  13. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
  14. package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
  15. package/src/components/filter-description/component.js +42 -42
  16. package/src/components/icon/component.js +33 -33
  17. package/src/components/input/index.js +2 -2
  18. package/src/components/input/input-number.js +2 -1
  19. package/src/components/loop/index.js +1 -1
  20. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  21. package/src/components/radio/index.js +1 -1
  22. package/src/components/sequence/index.js +1 -1
  23. package/src/components/subsequence/index.js +1 -1
  24. package/src/components/suggester/check-store.js +70 -70
  25. package/src/components/suggester/components/suggester-content.js +42 -42
  26. package/src/components/suggester/components/suggester.js +43 -3
  27. package/src/components/suggester/idb-suggester.js +7 -1
  28. package/src/components/suggester/lunatic-suggester.js +1 -0
  29. package/src/components/suggester/suggester-wrapper.js +6 -0
  30. package/src/components/tooltip/response.js +52 -52
  31. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  32. package/src/stories/icons/icons.stories.js +16 -16
  33. package/src/stories/questionnaire/kish.json +275 -0
  34. package/src/stories/questionnaire/logement-queen.json +23390 -23390
  35. package/src/stories/questionnaire/logement-s2.json +46027 -44536
  36. package/src/stories/questionnaire/questionnaire.stories.js +14 -2
  37. package/src/stories/utils/custom-lunatic.scss +23 -23
  38. package/src/stories/utils/orchestrator-split.js +4 -2
  39. package/src/stories/utils/orchestrator.js +4 -2
  40. package/src/tests/components/breadcrumb.spec.js +13 -13
  41. package/src/tests/components/button.spec.js +11 -11
  42. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  43. package/src/tests/components/checkbox-group.spec.js +53 -53
  44. package/src/tests/components/checkbox-one.spec.js +32 -32
  45. package/src/tests/components/datepicker.spec.js +22 -22
  46. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  47. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  48. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  49. package/src/tests/components/declarations.spec.js +46 -46
  50. package/src/tests/components/input.spec.js +18 -18
  51. package/src/tests/components/loops/loop-static.json +66 -66
  52. package/src/tests/components/loops/loop.json +258 -258
  53. package/src/tests/components/loops/loop.spec.js +30 -30
  54. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  55. package/src/tests/components/progress-bar.spec.js +15 -15
  56. package/src/tests/components/radio.spec.js +27 -27
  57. package/src/tests/components/sequence.spec.js +9 -9
  58. package/src/tests/components/subsequence.spec.js +9 -9
  59. package/src/tests/components/table.spec.js +11 -11
  60. package/src/tests/components/textarea.spec.js +18 -18
  61. package/src/tests/components/tooltip.spec.js +25 -25
  62. package/src/tests/setup/setupTests.js +4 -4
  63. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  64. package/src/tests/utils/lib/array.spec.js +22 -22
  65. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  66. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  67. package/src/tests/utils/lib/input-number.spec.js +18 -18
  68. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  69. package/src/tests/utils/lib/label-position.spec.js +22 -22
  70. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  71. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  72. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  73. package/src/tests/utils/lib/missing/mock.js +137 -137
  74. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  75. package/src/tests/utils/lib/responses.spec.js +64 -64
  76. package/src/tests/utils/lib/style.spec.js +26 -26
  77. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  78. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  79. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  80. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  81. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  82. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  83. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  84. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
  85. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  86. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  87. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  88. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  89. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  90. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  91. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  92. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  93. package/src/tests/utils/to-expose/state/results.js +78 -78
  94. package/src/utils/lib/splitting.js +55 -23
  95. package/src/utils/lib/tooltip/build-response.js +41 -41
  96. package/src/utils/store-tools/create/index.js +1 -1
  97. package/src/utils/store-tools/create/update-store-info.js +26 -26
  98. package/src/utils/store-tools/index.js +5 -5
  99. package/src/utils/to-expose/handler.js +12 -14
  100. package/src/utils/to-expose/hooks/lunatic-split.js +44 -27
  101. package/src/utils/to-expose/hooks/lunatic.js +12 -5
@@ -11,6 +11,7 @@ import logementSequence from './logement-sequence';
11
11
  import dataLogement from './data-logement';
12
12
  import simpsons from './simpsons';
13
13
  import arithmetic from './arithmetic';
14
+ import kish from './kish';
14
15
  import arithmeticManagement from './arithmetic-management';
15
16
  import updateExternalQuestionnaire from './update-external/questionnaire';
16
17
  import updateExternalData from './update-external/data';
@@ -79,7 +80,7 @@ const paginated = storiesOf('Questionnaire/Paginated', module).addDecorator(
79
80
  );
80
81
 
81
82
  paginated.addWithJSX('Calculated Variables', () => (
82
- <OrchestratorSplit
83
+ <Orchestrator
83
84
  id="props"
84
85
  source={calcVar}
85
86
  missing={boolean('Missing', false)}
@@ -92,6 +93,17 @@ paginated.addWithJSX('Calculated Variables', () => (
92
93
  />
93
94
  ));
94
95
 
96
+ paginated.addWithJSX('Kish', () => (
97
+ <Orchestrator
98
+ id="props"
99
+ source={kish}
100
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
101
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
102
+ disabled={boolean('Disabled', false)}
103
+ pagination
104
+ />
105
+ ));
106
+
95
107
  paginated.addWithJSX('Logement', () => (
96
108
  <OrchestratorSplit
97
109
  id="props"
@@ -157,7 +169,7 @@ paginated.addWithJSX('Logement - S2', () => (
157
169
  ));
158
170
 
159
171
  paginated.addWithJSX('Simpsons', () => (
160
- <OrchestratorSplit
172
+ <Orchestrator
161
173
  id="props"
162
174
  source={simpsons}
163
175
  missing={boolean('Missing', false)}
@@ -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
+ }
@@ -6,14 +6,16 @@ function getStoreInfoRequired() {
6
6
  return {};
7
7
  }
8
8
 
9
+ const defaultFeatures = ['VTL'];
10
+
9
11
  const OrchestratorForStories = ({
10
12
  source,
11
13
  suggesters,
12
- data = {},
14
+ data,
13
15
  management = false,
14
16
  pagination = false,
15
17
  modalForControls = false,
16
- features = ['VTL'],
18
+ features = defaultFeatures,
17
19
  bindings: initialBindings,
18
20
  initialPage = '1',
19
21
  getStoreInfo = getStoreInfoRequired,
@@ -6,14 +6,16 @@ function getStoreInfoRequired() {
6
6
  return {};
7
7
  }
8
8
 
9
+ const defaultFeatures = ['VTL'];
10
+
9
11
  const OrchestratorForStories = ({
10
12
  source,
11
13
  suggesters,
12
- data = {},
14
+ data,
13
15
  management = false,
14
16
  pagination = false,
15
17
  modalForControls = false,
16
- features = ['VTL'],
18
+ features = defaultFeatures,
17
19
  bindings: initialBindings,
18
20
  initialPage = '1',
19
21
  getStoreInfo = getStoreInfoRequired,
@@ -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
+ });