@inseefr/lunatic 0.3.1-experimental → 0.3.5-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 (61) hide show
  1. package/lib/index.js +218 -259
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -2
  4. package/src/components/component-wrapper/controls/validators/datepicker.js +25 -14
  5. package/src/components/component-wrapper/missing/component.js +37 -17
  6. package/src/components/datepicker/component.js +8 -12
  7. package/src/components/declarations/wrappers/input-declarations-wrapper.js +31 -9
  8. package/src/components/dropdown/commons/components/dropdown.js +21 -0
  9. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
  10. package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
  11. package/src/components/input/input-number.js +2 -1
  12. package/src/components/loop-constructor/block/index.js +1 -1
  13. package/src/components/loop-constructor/index.js +1 -1
  14. package/src/components/loop-constructor/roster/index.js +1 -1
  15. package/src/components/loop-constructor/wrapper/body-component.js +3 -0
  16. package/src/components/loop-constructor/wrapper/build-components.js +33 -33
  17. package/src/components/loop-constructor/wrapper/index.js +1 -1
  18. package/src/components/suggester/components/panel/option-container.js +1 -1
  19. package/src/components/suggester/components/suggester-content.js +42 -42
  20. package/src/components/suggester/components/suggester.js +43 -3
  21. package/src/components/suggester/idb-suggester.js +7 -1
  22. package/src/components/suggester/lunatic-suggester.js +1 -0
  23. package/src/components/suggester/suggester-wrapper.js +9 -3
  24. package/src/components/table/table.js +3 -1
  25. package/src/stories/loop-constructor/README.md +27 -27
  26. package/src/stories/loop-constructor/data-input-forced.json +64 -64
  27. package/src/stories/loop-constructor/data-input.json +100 -100
  28. package/src/stories/loop-constructor/data-loop-forced.json +66 -66
  29. package/src/stories/loop-constructor/data-loop-static-forced.json +66 -66
  30. package/src/stories/loop-constructor/data-loop-static.json +81 -81
  31. package/src/stories/loop-constructor/data-loop.json +81 -81
  32. package/src/stories/loop-constructor/data-roster-forced.json +68 -68
  33. package/src/stories/loop-constructor/data-roster.json +83 -83
  34. package/src/stories/loop-constructor/loop-constructor.stories.js +180 -180
  35. package/src/stories/questionnaire/arithmetic-management.json +47 -0
  36. package/src/stories/questionnaire/logement-queen.json +23389 -22705
  37. package/src/stories/questionnaire/logement-s2.json +46027 -44536
  38. package/src/stories/questionnaire/questionnaire.stories.js +12 -12
  39. package/src/stories/suggester/data.json +4 -1
  40. package/src/stories/suggester/suggester-workers.stories.js +4 -1
  41. package/src/stories/utils/orchestrator-split.js +119 -0
  42. package/src/stories/utils/orchestrator.js +4 -2
  43. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
  44. package/src/tests/utils/to-expose/state/state.spec.js +59 -59
  45. package/src/utils/lib/index.js +1 -0
  46. package/src/utils/lib/pagination/navigation/shared.js +5 -5
  47. package/src/utils/lib/splitting.js +142 -0
  48. package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +4 -2
  49. package/src/utils/suggester-workers/commons-tokenizer/filters/{filter-accents-to-lower.js → filter-accents.js} +2 -2
  50. package/src/utils/suggester-workers/commons-tokenizer/filters/{filter-accents-to-lower.spec.js → filter-accents.spec.js} +1 -1
  51. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +27 -1
  52. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +10 -0
  53. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +12 -0
  54. package/src/utils/suggester-workers/commons-tokenizer/index.js +1 -1
  55. package/src/utils/to-expose/handler.js +47 -28
  56. package/src/utils/to-expose/hooks/filter-components.js +106 -106
  57. package/src/utils/to-expose/hooks/index.js +2 -1
  58. package/src/utils/to-expose/hooks/lunatic-split.js +421 -0
  59. package/src/utils/to-expose/hooks/lunatic.js +23 -5
  60. package/src/utils/to-expose/index.js +11 -11
  61. package/src/utils/to-expose/state.js +23 -15
@@ -1,6 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { storiesOf } from '@storybook/react';
3
3
  import Orchestrator from '../utils/orchestrator';
4
+ import OrchestratorSplit from '../utils/orchestrator-split';
4
5
  import { titleDecorator } from 'utils/lib';
5
6
  import calcVar from './calc-var';
6
7
  import logement from './logement';
@@ -10,6 +11,7 @@ import logementSequence from './logement-sequence';
10
11
  import dataLogement from './data-logement';
11
12
  import simpsons from './simpsons';
12
13
  import arithmetic from './arithmetic';
14
+ import arithmeticManagement from './arithmetic-management';
13
15
  import updateExternalQuestionnaire from './update-external/questionnaire';
14
16
  import updateExternalData from './update-external/data';
15
17
  import { positioningOptions, featuresOptions } from '../utils/options';
@@ -35,26 +37,24 @@ def.addWithJSX('Calculated Variables', () => (
35
37
  />
36
38
  ));
37
39
 
38
- def.addWithJSX('Logement', () => (
40
+ def.addWithJSX('Arithmetic', () => (
39
41
  <Orchestrator
40
42
  id="props"
41
- source={logement}
42
- missing={boolean('Missing', false)}
43
+ source={arithmetic}
43
44
  features={select('Features', featuresOptions, ['VTL', 'MD'])}
44
45
  positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
45
46
  disabled={boolean('Disabled', false)}
46
- focused={boolean('Focused', false)}
47
- management={boolean('Management', false)}
48
47
  />
49
48
  ));
50
49
 
51
- def.addWithJSX('Arithmetic', () => (
50
+ def.addWithJSX('Arithmetic - Management', () => (
52
51
  <Orchestrator
53
52
  id="props"
54
- source={arithmetic}
53
+ source={arithmeticManagement}
55
54
  features={select('Features', featuresOptions, ['VTL', 'MD'])}
56
55
  positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
57
56
  disabled={boolean('Disabled', false)}
57
+ management={boolean('Management', true)}
58
58
  />
59
59
  ));
60
60
 
@@ -93,7 +93,7 @@ paginated.addWithJSX('Calculated Variables', () => (
93
93
  ));
94
94
 
95
95
  paginated.addWithJSX('Logement', () => (
96
- <Orchestrator
96
+ <OrchestratorSplit
97
97
  id="props"
98
98
  source={logement}
99
99
  data={dataLogement}
@@ -110,11 +110,11 @@ paginated.addWithJSX('Logement', () => (
110
110
  ));
111
111
 
112
112
  paginated.addWithJSX('Logement - Queen', () => (
113
- <Orchestrator
113
+ <OrchestratorSplit
114
114
  id="props"
115
115
  source={logementQueen}
116
116
  data={dataLogement}
117
- missing={boolean('Missing', false)}
117
+ missing={boolean('Missing', true)}
118
118
  activeGoNextForMissing={boolean('Active go next for missing', false)}
119
119
  features={select('Features', featuresOptions, ['VTL', 'MD'])}
120
120
  positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
@@ -126,7 +126,7 @@ paginated.addWithJSX('Logement - Queen', () => (
126
126
  ));
127
127
 
128
128
  paginated.addWithJSX('Logement - Sequence', () => (
129
- <Orchestrator
129
+ <OrchestratorSplit
130
130
  id="props"
131
131
  source={logementSequence}
132
132
  data={dataLogement}
@@ -142,7 +142,7 @@ paginated.addWithJSX('Logement - Sequence', () => (
142
142
  ));
143
143
 
144
144
  paginated.addWithJSX('Logement - S2', () => (
145
- <Orchestrator
145
+ <OrchestratorSplit
146
146
  id="props"
147
147
  source={logementS2}
148
148
  missing={boolean('Missing', false)}
@@ -46,7 +46,10 @@
46
46
  "name": "libelle2",
47
47
  "rules": ["[\\w]+"],
48
48
  "language": "French",
49
- "synonyms": { "st": ["saint"] },
49
+ "synonyms": [
50
+ { "source": "saint", "target": ["st"] },
51
+ { "source": "oph", "target": ["renaud", "nicolas"] }
52
+ ],
50
53
  "stemmer": false
51
54
  },
52
55
  { "name": "code" }
@@ -53,7 +53,10 @@ const bailleursSociaux = {
53
53
  rules: ['[\\w]+'],
54
54
  language: 'French',
55
55
  stemmer: false,
56
- synonyms: { saint: ['st'], sainte: ['ste'] },
56
+ synonyms: [
57
+ { source: 'saint', target: ['st'] },
58
+ { source: 'oph', target: ['renaud', 'nicolas'] },
59
+ ],
57
60
  },
58
61
  { name: 'code' },
59
62
  ],
@@ -0,0 +1,119 @@
1
+ import React, { useEffect } from 'react';
2
+ import * as lunatic from 'components';
3
+ import './custom-lunatic.scss';
4
+
5
+ function getStoreInfoRequired() {
6
+ return {};
7
+ }
8
+
9
+ const defaultFeatures = ['VTL'];
10
+
11
+ const OrchestratorForStories = ({
12
+ source,
13
+ suggesters,
14
+ data,
15
+ management = false,
16
+ pagination = false,
17
+ modalForControls = false,
18
+ features = defaultFeatures,
19
+ bindings: initialBindings,
20
+ initialPage = '1',
21
+ getStoreInfo = getStoreInfoRequired,
22
+ missing = false,
23
+ shortcut = false,
24
+ activeGoNextForMissing = false,
25
+ suggesterFetcher,
26
+ autoSuggesterLoading,
27
+ addExternal,
28
+ ...rest
29
+ }) => {
30
+ const preferences = management
31
+ ? ['COLLECTED', 'FORCED', 'EDITED']
32
+ : ['COLLECTED'];
33
+ const savingType = management ? 'EDITED' : 'COLLECTED';
34
+ const {
35
+ handleChange,
36
+ handleExternals,
37
+ components,
38
+ bindings,
39
+ pagination: {
40
+ goNext,
41
+ goPrevious,
42
+ page,
43
+ setPage,
44
+ maxPage,
45
+ isFirstPage,
46
+ isLastPage,
47
+ flow,
48
+ },
49
+ } = lunatic.useLunaticSplit(source, data, {
50
+ suggesters,
51
+ savingType,
52
+ preferences,
53
+ features,
54
+ management,
55
+ pagination,
56
+ modalForControls,
57
+ initialPage,
58
+ suggesterFetcher,
59
+ autoSuggesterLoading,
60
+ });
61
+
62
+ useEffect(() => {
63
+ handleExternals(addExternal);
64
+ }, [addExternal, handleExternals]);
65
+
66
+ const Button = lunatic.Button;
67
+
68
+ const missingStrategy = (b) => goNext(null, b);
69
+
70
+ return (
71
+ <div className="container">
72
+ <div className="components">
73
+ {components.map((q) => {
74
+ const { id, componentType } = q;
75
+ const Component = lunatic[componentType];
76
+ const { storeName } = q;
77
+
78
+ return (
79
+ <div className="lunatic lunatic-component" key={`component-${id}`}>
80
+ <Component
81
+ {...rest}
82
+ {...q}
83
+ {...getStoreInfo(storeName)}
84
+ handleChange={handleChange}
85
+ preferences={preferences}
86
+ savingType={savingType}
87
+ management={management}
88
+ features={features}
89
+ bindings={{ ...bindings, ...initialBindings }}
90
+ currentPage={page}
91
+ setPage={setPage}
92
+ flow={flow}
93
+ pagination={pagination}
94
+ missing={missing}
95
+ shortcut={shortcut}
96
+ missingStrategy={activeGoNextForMissing && missingStrategy}
97
+ />
98
+ </div>
99
+ );
100
+ })}
101
+ </div>
102
+ {pagination && (
103
+ <>
104
+ <div className="pagination">
105
+ <Button
106
+ onClick={goPrevious}
107
+ disabled={isFirstPage}
108
+ value="Previous"
109
+ />
110
+ <Button onClick={goNext} disabled={isLastPage} value="Next" />
111
+ </div>
112
+ <div>{`Page : ${page}/${maxPage}`}</div>
113
+ </>
114
+ )}
115
+ </div>
116
+ );
117
+ };
118
+
119
+ export default OrchestratorForStories;
@@ -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,158 +1,158 @@
1
- {
2
- "components": [
3
- { "id": "1", "componentType": "Sequence", "depth": 1 },
4
- {
5
- "id": "2",
6
- "componentType": "Input",
7
- "response": {
8
- "name": "inputOk",
9
- "values": {
10
- "PREVIOUS": null,
11
- "COLLECTED": "My input",
12
- "FORCED": null,
13
- "EDITED": "My new input",
14
- "INPUTED": null
15
- }
16
- },
17
- "depth": 1
18
- },
19
- {
20
- "id": "3",
21
- "componentType": "CheckboxGroup",
22
- "responses": [
23
- {
24
- "response": {
25
- "name": "check1",
26
- "values": {
27
- "PREVIOUS": null,
28
- "COLLECTED": true,
29
- "FORCED": null,
30
- "EDITED": null,
31
- "INPUTED": null
32
- }
33
- }
34
- },
35
- {
36
- "response": {
37
- "name": "check2",
38
- "values": {
39
- "PREVIOUS": null,
40
- "COLLECTED": false,
41
- "FORCED": true,
42
- "EDITED": null,
43
- "INPUTED": null
44
- }
45
- }
46
- }
47
- ],
48
- "depth": 1
49
- },
50
- {
51
- "id": "4",
52
- "componentType": "Table",
53
- "cells": [
54
- [
55
- { "label": "label", "depth": 1 },
56
- {
57
- "componentType": "Radio",
58
- "response": {
59
- "name": "table11",
60
- "values": {
61
- "PREVIOUS": null,
62
- "COLLECTED": "1",
63
- "FORCED": null,
64
- "EDITED": null,
65
- "INPUTED": null
66
- }
67
- },
68
- "depth": 1
69
- }
70
- ]
71
- ],
72
- "depth": 1
73
- },
74
- {
75
- "id": "5",
76
- "componentType": "RosterForLoop",
77
- "components": [
78
- {
79
- "componentType": "Input",
80
- "response": {
81
- "name": "Roster",
82
- "values": {
83
- "PREVIOUS": [null],
84
- "COLLECTED": ["ok"],
85
- "FORCED": [null],
86
- "EDITED": [null],
87
- "INPUTED": [null]
88
- }
89
- },
90
- "depth": 2
91
- }
92
- ],
93
- "depth": 1
94
- }
95
- ],
96
- "variables": {
97
- "EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
98
- "CALCULATED": {
99
- "Test": {
100
- "expression": "inputOk || \" ok\"",
101
- "value": "My input ok",
102
- "bindingDependencies": ["inputOk"]
103
- }
104
- },
105
- "COLLECTED": {
106
- "inputOk": {
107
- "componentRef": "2",
108
- "values": {
109
- "PREVIOUS": null,
110
- "COLLECTED": "My input",
111
- "FORCED": null,
112
- "EDITED": "My new input",
113
- "INPUTED": null
114
- }
115
- },
116
- "check1": {
117
- "componentRef": "3",
118
- "values": {
119
- "PREVIOUS": null,
120
- "COLLECTED": true,
121
- "FORCED": null,
122
- "EDITED": null,
123
- "INPUTED": null
124
- }
125
- },
126
- "check2": {
127
- "componentRef": "3",
128
- "values": {
129
- "PREVIOUS": null,
130
- "COLLECTED": false,
131
- "FORCED": true,
132
- "EDITED": null,
133
- "INPUTED": null
134
- }
135
- },
136
- "table11": {
137
- "componentRef": "4",
138
- "values": {
139
- "PREVIOUS": null,
140
- "COLLECTED": "1",
141
- "FORCED": null,
142
- "EDITED": null,
143
- "INPUTED": null
144
- }
145
- },
146
- "Roster": {
147
- "componentRef": "5",
148
- "values": {
149
- "PREVIOUS": [null],
150
- "COLLECTED": ["ok"],
151
- "FORCED": [null],
152
- "EDITED": [null],
153
- "INPUTED": [null]
154
- }
155
- }
156
- }
157
- }
158
- }
1
+ {
2
+ "components": [
3
+ { "id": "1", "componentType": "Sequence", "depth": 1 },
4
+ {
5
+ "id": "2",
6
+ "componentType": "Input",
7
+ "response": {
8
+ "name": "inputOk",
9
+ "values": {
10
+ "PREVIOUS": null,
11
+ "COLLECTED": "My input",
12
+ "FORCED": null,
13
+ "EDITED": "My new input",
14
+ "INPUTED": null
15
+ }
16
+ },
17
+ "depth": 1
18
+ },
19
+ {
20
+ "id": "3",
21
+ "componentType": "CheckboxGroup",
22
+ "responses": [
23
+ {
24
+ "response": {
25
+ "name": "check1",
26
+ "values": {
27
+ "PREVIOUS": null,
28
+ "COLLECTED": true,
29
+ "FORCED": null,
30
+ "EDITED": null,
31
+ "INPUTED": null
32
+ }
33
+ }
34
+ },
35
+ {
36
+ "response": {
37
+ "name": "check2",
38
+ "values": {
39
+ "PREVIOUS": null,
40
+ "COLLECTED": false,
41
+ "FORCED": true,
42
+ "EDITED": null,
43
+ "INPUTED": null
44
+ }
45
+ }
46
+ }
47
+ ],
48
+ "depth": 1
49
+ },
50
+ {
51
+ "id": "4",
52
+ "componentType": "Table",
53
+ "cells": [
54
+ [
55
+ { "label": "label", "depth": 1 },
56
+ {
57
+ "componentType": "Radio",
58
+ "response": {
59
+ "name": "table11",
60
+ "values": {
61
+ "PREVIOUS": null,
62
+ "COLLECTED": "1",
63
+ "FORCED": null,
64
+ "EDITED": null,
65
+ "INPUTED": null
66
+ }
67
+ },
68
+ "depth": 1
69
+ }
70
+ ]
71
+ ],
72
+ "depth": 1
73
+ },
74
+ {
75
+ "id": "5",
76
+ "componentType": "RosterForLoop",
77
+ "components": [
78
+ {
79
+ "componentType": "Input",
80
+ "response": {
81
+ "name": "Roster",
82
+ "values": {
83
+ "PREVIOUS": [null],
84
+ "COLLECTED": ["ok"],
85
+ "FORCED": [null],
86
+ "EDITED": [null],
87
+ "INPUTED": [null]
88
+ }
89
+ },
90
+ "depth": 2
91
+ }
92
+ ],
93
+ "depth": 1
94
+ }
95
+ ],
96
+ "variables": {
97
+ "EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
98
+ "CALCULATED": {
99
+ "Test": {
100
+ "expression": "inputOk || \" ok\"",
101
+ "value": "My new input ok",
102
+ "bindingDependencies": ["inputOk"]
103
+ }
104
+ },
105
+ "COLLECTED": {
106
+ "inputOk": {
107
+ "componentRef": "2",
108
+ "values": {
109
+ "PREVIOUS": null,
110
+ "COLLECTED": "My input",
111
+ "FORCED": null,
112
+ "EDITED": "My new input",
113
+ "INPUTED": null
114
+ }
115
+ },
116
+ "check1": {
117
+ "componentRef": "3",
118
+ "values": {
119
+ "PREVIOUS": null,
120
+ "COLLECTED": true,
121
+ "FORCED": null,
122
+ "EDITED": null,
123
+ "INPUTED": null
124
+ }
125
+ },
126
+ "check2": {
127
+ "componentRef": "3",
128
+ "values": {
129
+ "PREVIOUS": null,
130
+ "COLLECTED": false,
131
+ "FORCED": true,
132
+ "EDITED": null,
133
+ "INPUTED": null
134
+ }
135
+ },
136
+ "table11": {
137
+ "componentRef": "4",
138
+ "values": {
139
+ "PREVIOUS": null,
140
+ "COLLECTED": "1",
141
+ "FORCED": null,
142
+ "EDITED": null,
143
+ "INPUTED": null
144
+ }
145
+ },
146
+ "Roster": {
147
+ "componentRef": "5",
148
+ "values": {
149
+ "PREVIOUS": [null],
150
+ "COLLECTED": ["ok"],
151
+ "FORCED": [null],
152
+ "EDITED": [null],
153
+ "INPUTED": [null]
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
@@ -1,59 +1,59 @@
1
- import {
2
- getState,
3
- getCollectedState,
4
- getCollectedStateByValueType,
5
- getBindings,
6
- } from 'utils/to-expose/state';
7
- import questionnaire from './questionnaire';
8
- import * as R from './results';
9
-
10
- describe('state', () => {
11
- describe('getState', () => {
12
- it('should return empty object', () => {
13
- expect(getState([])).toEqual({
14
- COLLECTED: {},
15
- CALCULATED: {},
16
- EXTERNAL: {},
17
- });
18
- });
19
- it('should return object', () => {
20
- expect(getState(questionnaire)).toEqual(R.state);
21
- });
22
- });
23
- describe('getCollectedState', () => {
24
- it('should return empty object', () => {
25
- expect(getCollectedState([])).toEqual({});
26
- });
27
- it('should return object', () => {
28
- expect(getCollectedState(questionnaire)).toEqual(R.collectedState);
29
- });
30
- });
31
- describe('getCollectedStateByValueType', () => {
32
- it('should return empty object', () => {
33
- expect(getCollectedStateByValueType([])('')).toEqual({});
34
- expect(getCollectedStateByValueType(questionnaire)('')).toEqual({});
35
- });
36
- it('should return object', () => {
37
- expect(getCollectedStateByValueType(questionnaire)('COLLECTED')).toEqual(
38
- R.collectedStateCollected
39
- );
40
- expect(getCollectedStateByValueType(questionnaire)('FORCED')).toEqual(
41
- R.collectedStateForced
42
- );
43
- expect(
44
- getCollectedStateByValueType(questionnaire)('COLLECTED', true)
45
- ).toEqual(R.collectedStateCollectedWithNull);
46
- expect(
47
- getCollectedStateByValueType(questionnaire)('FORCED', true)
48
- ).toEqual(R.collectedStateForcedWithNull);
49
- });
50
- });
51
- describe('getBindings', () => {
52
- it('should return empty object', () => {
53
- expect(getBindings([])).toEqual({});
54
- });
55
- it('should return object', () => {
56
- expect(getBindings(questionnaire)).toEqual(R.bindingsResults);
57
- });
58
- });
59
- });
1
+ import {
2
+ getState,
3
+ getCollectedState,
4
+ getCollectedStateByValueType,
5
+ getBindings,
6
+ } from 'utils/to-expose/state';
7
+ import questionnaire from './questionnaire';
8
+ import * as R from './results';
9
+
10
+ describe('state', () => {
11
+ describe('getState', () => {
12
+ it('should return empty object', () => {
13
+ expect(getState([])).toEqual({
14
+ COLLECTED: {},
15
+ CALCULATED: {},
16
+ EXTERNAL: {},
17
+ });
18
+ });
19
+ it('should return object', () => {
20
+ expect(getState(questionnaire)).toEqual(R.state);
21
+ });
22
+ });
23
+ describe('getCollectedState', () => {
24
+ it('should return empty object', () => {
25
+ expect(getCollectedState([])).toEqual({});
26
+ });
27
+ it('should return object', () => {
28
+ expect(getCollectedState(questionnaire)).toEqual(R.collectedState);
29
+ });
30
+ });
31
+ describe('getCollectedStateByValueType', () => {
32
+ it('should return empty object', () => {
33
+ expect(getCollectedStateByValueType([])('')).toEqual({});
34
+ expect(getCollectedStateByValueType(questionnaire)('')).toEqual({});
35
+ });
36
+ it('should return object', () => {
37
+ expect(getCollectedStateByValueType(questionnaire)('COLLECTED')).toEqual(
38
+ R.collectedStateCollected
39
+ );
40
+ expect(getCollectedStateByValueType(questionnaire)('FORCED')).toEqual(
41
+ R.collectedStateForced
42
+ );
43
+ expect(
44
+ getCollectedStateByValueType(questionnaire)('COLLECTED', true)
45
+ ).toEqual(R.collectedStateCollectedWithNull);
46
+ expect(
47
+ getCollectedStateByValueType(questionnaire)('FORCED', true)
48
+ ).toEqual(R.collectedStateForcedWithNull);
49
+ });
50
+ });
51
+ describe('getBindings', () => {
52
+ it('should return empty object', () => {
53
+ expect(getBindings([])).toEqual({});
54
+ });
55
+ it('should return object', () => {
56
+ expect(getBindings(questionnaire)).toEqual(R.bindingsResults);
57
+ });
58
+ });
59
+ });