@inseefr/lunatic 3.9.0 → 3.9.1-rc-react19.1
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/components/Input/Input.spec.js +1 -1
- package/components/Input/Input.spec.js.map +1 -1
- package/components/Roundabout/roundabout.spec.js +1 -1
- package/components/Roundabout/roundabout.spec.js.map +1 -1
- package/components/Textarea/Textarea.spec.js +1 -1
- package/components/Textarea/Textarea.spec.js.map +1 -1
- package/esm/components/Input/Input.spec.js +1 -1
- package/esm/components/Input/Input.spec.js.map +1 -1
- package/esm/components/Roundabout/roundabout.spec.js +1 -1
- package/esm/components/Roundabout/roundabout.spec.js.map +1 -1
- package/esm/components/Textarea/Textarea.spec.js +1 -1
- package/esm/components/Textarea/Textarea.spec.js.map +1 -1
- package/esm/hooks/useRefSync.d.ts +1 -1
- package/hooks/useRefSync.d.ts +1 -1
- package/package.json +6 -6
- package/src/components/Input/Input.spec.tsx +1 -1
- package/src/components/Roundabout/roundabout.spec.tsx +1 -1
- package/src/components/Textarea/Textarea.spec.tsx +1 -1
- package/src/stories/behaviour/overview/sourceLoop.json +306 -1228
- package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +0 -646
- package/src/use-lunatic/use-lunatic.test.ts +33 -25
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -188,46 +188,54 @@ describe('use-lunatic()', () => {
|
|
|
188
188
|
|
|
189
189
|
describe('with loop', function () {
|
|
190
190
|
const data = dataFromObject({
|
|
191
|
-
ETAT: '1',
|
|
192
|
-
SATISFAIT: '1',
|
|
193
191
|
T_NHAB: 3,
|
|
194
192
|
T_PRENOM: ['Quentin', 'Luna', 'Paul'],
|
|
195
|
-
COMMCOMPO: 'super',
|
|
196
|
-
T_SEXE: ['1', '2', '1'],
|
|
197
|
-
T_DATENAIS: [null, null, null],
|
|
198
|
-
REMARQUES: [null, 'a', 'b'],
|
|
199
|
-
SUPERQUEST: ['ok', 'ok', null],
|
|
200
|
-
AUTRESUPERQUEST: ['a', 'c', 'ras'],
|
|
201
|
-
ENCOREUNEQ: ['wow', 'b', null],
|
|
202
|
-
COMMENT_QE: null,
|
|
203
|
-
ETAT_MISSING: null,
|
|
204
|
-
SATISFAIT_MISSING: null,
|
|
205
|
-
T_NHAB_MISSING: null,
|
|
206
|
-
T_PRENOM_MISSING: null,
|
|
207
|
-
COMMCOMPO_MISSING: null,
|
|
208
|
-
T_SEXE_MISSING: null,
|
|
209
|
-
T_DATENAIS_MISSING: [null, 'DK', 'RF'],
|
|
210
|
-
REMARQUES_MISSING: [null, null, null],
|
|
211
|
-
SUPERQUEST_MISSING: [null, null, 'DK'],
|
|
212
|
-
ENCOREUNEQ_MISSING: [null, null, 'RF'],
|
|
213
|
-
AUTRESUPERQUEST_MISSING: null,
|
|
214
|
-
COMMENT_QE_MISSING: null,
|
|
215
193
|
});
|
|
216
194
|
|
|
217
195
|
it('should work with loop', async () => {
|
|
218
196
|
const { result } = renderHook(() =>
|
|
219
197
|
useLunatic(sourceOverview, data, lunaticConfiguration)
|
|
220
198
|
);
|
|
221
|
-
|
|
199
|
+
|
|
200
|
+
// 4 sequences, and we loop twice on the second one
|
|
201
|
+
expect(result.current.overview.length).toBe(5);
|
|
202
|
+
expect(result.current.overview[0].label).toBe(
|
|
203
|
+
'I - Habitants du logement'
|
|
204
|
+
);
|
|
205
|
+
expect(result.current.overview[0].page).toBe('1');
|
|
206
|
+
expect(result.current.overview[1].label).toBe(
|
|
207
|
+
'II - Boucle sur séquence pour Luna (qui filtre la première itération)'
|
|
208
|
+
);
|
|
209
|
+
expect(result.current.overview[1].page).toBe('4.1#2');
|
|
210
|
+
expect(result.current.overview[2].label).toBe(
|
|
211
|
+
'II - Boucle sur séquence pour Paul (qui filtre la première itération)'
|
|
212
|
+
);
|
|
213
|
+
expect(result.current.overview[2].page).toBe('4.1#3');
|
|
214
|
+
|
|
215
|
+
// 3rd sequence has only one subsequence, and we loop over it
|
|
216
|
+
expect(result.current.overview[3].children.length).toBe(2);
|
|
217
|
+
expect(result.current.overview[3].children[0].page).toBe('6.1#2');
|
|
218
|
+
expect(result.current.overview[3].children[1].page).toBe('6.1#3');
|
|
219
|
+
|
|
220
|
+
// It would be nice to test that each label is correct, currently we have issue about expression execution in subsequence in tests only.
|
|
222
221
|
});
|
|
223
222
|
it('should handle initialPage', async () => {
|
|
224
223
|
const { result } = renderHook(() =>
|
|
225
224
|
useLunatic(sourceOverview, data, {
|
|
226
225
|
...lunaticConfiguration,
|
|
227
|
-
initialPage: '
|
|
226
|
+
initialPage: '6.1#2',
|
|
228
227
|
})
|
|
229
228
|
);
|
|
230
|
-
|
|
229
|
+
|
|
230
|
+
// 4 sequences, and we loop twice on the second one
|
|
231
|
+
expect(result.current.overview.length).toBe(5);
|
|
232
|
+
expect(result.current.overview[1].reached).toBe(true);
|
|
233
|
+
expect(result.current.overview[3].children[0].reached).toBe(true);
|
|
234
|
+
expect(result.current.overview[3].children[1].reached).toBe(false);
|
|
235
|
+
expect(result.current.overview[4].reached).toBe(false);
|
|
236
|
+
|
|
237
|
+
expect(result.current.overview[3].current).toBe(true);
|
|
238
|
+
expect(result.current.overview[3].children[0].current).toBe(true);
|
|
231
239
|
});
|
|
232
240
|
});
|
|
233
241
|
});
|