@inseefr/lunatic 0.3.5-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.
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- 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/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/tooltip/response.js +52 -52
- package/src/stories/checkbox-boolean/data-forced.json +48 -48
- 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
- package/src/utils/to-expose/handler.js +12 -14
- package/src/utils/to-expose/hooks/lunatic-split.js +5 -2
- package/src/utils/to-expose/hooks/lunatic.js +5 -2
|
@@ -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
|
+
});
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { Declarations } from 'components';
|
|
4
|
-
import * as C from '../../constants';
|
|
5
|
-
|
|
6
|
-
const defaultProps = { id: 'id', label: 'label' };
|
|
7
|
-
const declarations = [
|
|
8
|
-
{
|
|
9
|
-
position: C.AFTER_QUESTION_TEXT,
|
|
10
|
-
id: 'id1',
|
|
11
|
-
label: 'label',
|
|
12
|
-
declarationType: C.INSTRUCTION,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
position: C.BEFORE_QUESTION_TEXT,
|
|
16
|
-
id: 'id2',
|
|
17
|
-
label: 'label',
|
|
18
|
-
declarationType: C.INSTRUCTION,
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
describe('declarations', () => {
|
|
23
|
-
it('minimalist renders without crashing', () => {
|
|
24
|
-
shallow(<Declarations {...defaultProps} />);
|
|
25
|
-
});
|
|
26
|
-
it('returns no declaration', () => {
|
|
27
|
-
const wrapper = shallow(
|
|
28
|
-
<Declarations
|
|
29
|
-
{...defaultProps}
|
|
30
|
-
type={C.DETACHABLE}
|
|
31
|
-
declarations={declarations}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
expect(wrapper.find('.declarations-lunatic').children()).toHaveLength(0);
|
|
35
|
-
});
|
|
36
|
-
it('returns one declaration', () => {
|
|
37
|
-
const wrapper = shallow(
|
|
38
|
-
<Declarations
|
|
39
|
-
{...defaultProps}
|
|
40
|
-
type={C.AFTER_QUESTION_TEXT}
|
|
41
|
-
declarations={declarations}
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
expect(wrapper.find('.declarations-lunatic').children()).toHaveLength(1);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { Declarations } from 'components';
|
|
4
|
+
import * as C from '../../constants';
|
|
5
|
+
|
|
6
|
+
const defaultProps = { id: 'id', label: 'label' };
|
|
7
|
+
const declarations = [
|
|
8
|
+
{
|
|
9
|
+
position: C.AFTER_QUESTION_TEXT,
|
|
10
|
+
id: 'id1',
|
|
11
|
+
label: 'label',
|
|
12
|
+
declarationType: C.INSTRUCTION,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
position: C.BEFORE_QUESTION_TEXT,
|
|
16
|
+
id: 'id2',
|
|
17
|
+
label: 'label',
|
|
18
|
+
declarationType: C.INSTRUCTION,
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
describe('declarations', () => {
|
|
23
|
+
it('minimalist renders without crashing', () => {
|
|
24
|
+
shallow(<Declarations {...defaultProps} />);
|
|
25
|
+
});
|
|
26
|
+
it('returns no declaration', () => {
|
|
27
|
+
const wrapper = shallow(
|
|
28
|
+
<Declarations
|
|
29
|
+
{...defaultProps}
|
|
30
|
+
type={C.DETACHABLE}
|
|
31
|
+
declarations={declarations}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
expect(wrapper.find('.declarations-lunatic').children()).toHaveLength(0);
|
|
35
|
+
});
|
|
36
|
+
it('returns one declaration', () => {
|
|
37
|
+
const wrapper = shallow(
|
|
38
|
+
<Declarations
|
|
39
|
+
{...defaultProps}
|
|
40
|
+
type={C.AFTER_QUESTION_TEXT}
|
|
41
|
+
declarations={declarations}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
expect(wrapper.find('.declarations-lunatic').children()).toHaveLength(1);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { Input } from 'components';
|
|
4
|
-
|
|
5
|
-
const handleChange = jest.fn();
|
|
6
|
-
const defaultProps = { id: 'id', label: 'label', handleChange };
|
|
7
|
-
|
|
8
|
-
describe('input', () => {
|
|
9
|
-
it('renders without crashing', () => {
|
|
10
|
-
shallow(<Input {...defaultProps} />);
|
|
11
|
-
});
|
|
12
|
-
it('returns management component', () => {
|
|
13
|
-
shallow(<Input {...defaultProps} label="label" management />);
|
|
14
|
-
});
|
|
15
|
-
it('returns disabled & readOnly component', () => {
|
|
16
|
-
shallow(<Input {...defaultProps} label="label" disabled readOnly />);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { Input } from 'components';
|
|
4
|
+
|
|
5
|
+
const handleChange = jest.fn();
|
|
6
|
+
const defaultProps = { id: 'id', label: 'label', handleChange };
|
|
7
|
+
|
|
8
|
+
describe('input', () => {
|
|
9
|
+
it('renders without crashing', () => {
|
|
10
|
+
shallow(<Input {...defaultProps} />);
|
|
11
|
+
});
|
|
12
|
+
it('returns management component', () => {
|
|
13
|
+
shallow(<Input {...defaultProps} label="label" management />);
|
|
14
|
+
});
|
|
15
|
+
it('returns disabled & readOnly component', () => {
|
|
16
|
+
shallow(<Input {...defaultProps} label="label" disabled readOnly />);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
{
|
|
2
|
-
"components": [
|
|
3
|
-
{
|
|
4
|
-
"id": "k3ylzyo4",
|
|
5
|
-
"componentType": "Loop",
|
|
6
|
-
"mandatory": true,
|
|
7
|
-
"positioning": "HORIZONTAL",
|
|
8
|
-
"label": "\"Ajouter un individu\"",
|
|
9
|
-
"conditionFilter": { "value": "true" },
|
|
10
|
-
"bindingDependencies": ["PRENOM", "AGE"],
|
|
11
|
-
"lines": { "min": "3", "max": "3" },
|
|
12
|
-
"components": [
|
|
13
|
-
{
|
|
14
|
-
"componentType": "Input",
|
|
15
|
-
"label": "Prénom",
|
|
16
|
-
"conditionFilter": { "value": "true" },
|
|
17
|
-
"maxLength": 30,
|
|
18
|
-
"bindingDependencies": ["PRENOM"],
|
|
19
|
-
"id": "k3yn2qmr",
|
|
20
|
-
"response": {
|
|
21
|
-
"name": "PRENOM"
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"componentType": "InputNumber",
|
|
26
|
-
"label": "Age",
|
|
27
|
-
"conditionFilter": { "value": "true" },
|
|
28
|
-
"min": 0,
|
|
29
|
-
"max": 120,
|
|
30
|
-
"decimals": 0,
|
|
31
|
-
"bindingDependencies": ["AGE"],
|
|
32
|
-
"id": "k3ymundt",
|
|
33
|
-
"response": {
|
|
34
|
-
"name": "AGE"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
"variables": [
|
|
41
|
-
{
|
|
42
|
-
"variableType": "COLLECTED",
|
|
43
|
-
"name": "PRENOM",
|
|
44
|
-
"componentRef": "k3ylzyo4",
|
|
45
|
-
"values": {
|
|
46
|
-
"PREVIOUS": [null],
|
|
47
|
-
"COLLECTED": ["Marco"],
|
|
48
|
-
"FORCED": [null],
|
|
49
|
-
"EDITED": [null],
|
|
50
|
-
"INPUTED": [null]
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"variableType": "COLLECTED",
|
|
55
|
-
"name": "AGE",
|
|
56
|
-
"componentRef": "k3ylzyo4",
|
|
57
|
-
"values": {
|
|
58
|
-
"PREVIOUS": [null],
|
|
59
|
-
"COLLECTED": ["28"],
|
|
60
|
-
"FORCED": [null],
|
|
61
|
-
"EDITED": [null],
|
|
62
|
-
"INPUTED": [null]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"id": "k3ylzyo4",
|
|
5
|
+
"componentType": "Loop",
|
|
6
|
+
"mandatory": true,
|
|
7
|
+
"positioning": "HORIZONTAL",
|
|
8
|
+
"label": "\"Ajouter un individu\"",
|
|
9
|
+
"conditionFilter": { "value": "true" },
|
|
10
|
+
"bindingDependencies": ["PRENOM", "AGE"],
|
|
11
|
+
"lines": { "min": "3", "max": "3" },
|
|
12
|
+
"components": [
|
|
13
|
+
{
|
|
14
|
+
"componentType": "Input",
|
|
15
|
+
"label": "Prénom",
|
|
16
|
+
"conditionFilter": { "value": "true" },
|
|
17
|
+
"maxLength": 30,
|
|
18
|
+
"bindingDependencies": ["PRENOM"],
|
|
19
|
+
"id": "k3yn2qmr",
|
|
20
|
+
"response": {
|
|
21
|
+
"name": "PRENOM"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"componentType": "InputNumber",
|
|
26
|
+
"label": "Age",
|
|
27
|
+
"conditionFilter": { "value": "true" },
|
|
28
|
+
"min": 0,
|
|
29
|
+
"max": 120,
|
|
30
|
+
"decimals": 0,
|
|
31
|
+
"bindingDependencies": ["AGE"],
|
|
32
|
+
"id": "k3ymundt",
|
|
33
|
+
"response": {
|
|
34
|
+
"name": "AGE"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"variables": [
|
|
41
|
+
{
|
|
42
|
+
"variableType": "COLLECTED",
|
|
43
|
+
"name": "PRENOM",
|
|
44
|
+
"componentRef": "k3ylzyo4",
|
|
45
|
+
"values": {
|
|
46
|
+
"PREVIOUS": [null],
|
|
47
|
+
"COLLECTED": ["Marco"],
|
|
48
|
+
"FORCED": [null],
|
|
49
|
+
"EDITED": [null],
|
|
50
|
+
"INPUTED": [null]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"variableType": "COLLECTED",
|
|
55
|
+
"name": "AGE",
|
|
56
|
+
"componentRef": "k3ylzyo4",
|
|
57
|
+
"values": {
|
|
58
|
+
"PREVIOUS": [null],
|
|
59
|
+
"COLLECTED": ["28"],
|
|
60
|
+
"FORCED": [null],
|
|
61
|
+
"EDITED": [null],
|
|
62
|
+
"INPUTED": [null]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|