@inseefr/lunatic 3.12.3 → 3.13.0
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/esm/type.source.d.ts +1 -0
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +44 -11
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +47 -0
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/checkbox/sourceOneDynamicOptions.json +16 -1
- package/src/stories/dropdown/sourceDynamicOptions.json +16 -1
- package/src/stories/radio/sourceDynamicOptions.json +16 -1
- package/src/type.source.ts +1 -0
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +74 -21
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +59 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +1 -0
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +44 -11
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +47 -0
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
|
@@ -572,6 +572,65 @@ describe('lunatic-variables-store', () => {
|
|
|
572
572
|
variables.set('PRENOM', ['John', 'Jane']);
|
|
573
573
|
expect(variables.get('AGE')).toEqual([null, null]);
|
|
574
574
|
});
|
|
575
|
+
it('should check every iteration when configured from an iterated source change', () => {
|
|
576
|
+
// Given
|
|
577
|
+
variables.set('PRENOM', ['Marc', 'Marc', 'Marc']);
|
|
578
|
+
variables.set('QCU', ['A', 'B', 'B']);
|
|
579
|
+
cleaningBehaviour(
|
|
580
|
+
variables,
|
|
581
|
+
{
|
|
582
|
+
PRENOM: {
|
|
583
|
+
QCU: [
|
|
584
|
+
{
|
|
585
|
+
expression: 'PRENOM <> "Marc"',
|
|
586
|
+
shapeFrom: 'PRENOM',
|
|
587
|
+
isAggregatorUsed: false,
|
|
588
|
+
shouldCheckAllIterations: true,
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
{ PRENOM: [], QCU: [null] }
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
// When
|
|
597
|
+
variables.set('PRENOM', 'Patrick', { iteration: [0] });
|
|
598
|
+
|
|
599
|
+
// Then
|
|
600
|
+
expect(variables.get('QCU')).toEqual(['A', null, null]);
|
|
601
|
+
});
|
|
602
|
+
it('should handle simultaneously expressions that should check every iteration and expression that should not ', () => {
|
|
603
|
+
// Given
|
|
604
|
+
variables.set('PRENOM', ['Marc', 'Marc', 'Marc']);
|
|
605
|
+
variables.set('QCU', ['A', 'B', 'B']);
|
|
606
|
+
cleaningBehaviour(
|
|
607
|
+
variables,
|
|
608
|
+
{
|
|
609
|
+
PRENOM: {
|
|
610
|
+
QCU: [
|
|
611
|
+
{
|
|
612
|
+
expression: 'PRENOM <> ""',
|
|
613
|
+
shapeFrom: 'PRENOM',
|
|
614
|
+
isAggregatorUsed: false,
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
expression: 'PRENOM <> "Marc"',
|
|
618
|
+
shapeFrom: 'PRENOM',
|
|
619
|
+
isAggregatorUsed: false,
|
|
620
|
+
shouldCheckAllIterations: true,
|
|
621
|
+
},
|
|
622
|
+
],
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
{ PRENOM: [], QCU: [null] }
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
// When
|
|
629
|
+
variables.set('PRENOM', '', { iteration: [0] });
|
|
630
|
+
|
|
631
|
+
// Then
|
|
632
|
+
expect(variables.get('QCU')).toEqual([null, null, null]);
|
|
633
|
+
});
|
|
575
634
|
it('should clean pairwise in two directions', () => {
|
|
576
635
|
variables.set('LINKS', [
|
|
577
636
|
[null, '1', '3'],
|