-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathrepeat.test.ts
More file actions
29 lines (23 loc) · 1.28 KB
/
repeat.test.ts
File metadata and controls
29 lines (23 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { updateFieldIdInExpression } from './helpers';
describe('RepeatingFieldComponent - handleExpressionFieldIdUpdate', () => {
it('Should handle update of expression with ids in repeat group', () => {
const expression =
"infantStatus !== '151849AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' && infantStatus !== '154223AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'";
const fieldIds = ['birthDate', 'infantStatus', 'deathDate'];
const index = 2;
const updatedExpression = updateFieldIdInExpression(expression, index, fieldIds);
expect(updatedExpression).toEqual(
"infantStatus_2 !== '151849AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' && infantStatus_2 !== '154223AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'",
);
});
it('Should handle update of expression with ids not in repeat group', () => {
const expression =
"myValue > today() || myValue <= '1/1/1890' || myValue > useFieldValue('visit_date') || myValue < useFieldValue('visit_date')";
const fieldIds = ['birthDate', 'infantStatus', 'deathDate'];
const index = 1;
const updatedExpression = updateFieldIdInExpression(expression, index, fieldIds);
expect(updatedExpression).toEqual(
"myValue > today() || myValue <= '1/1/1890' || myValue > useFieldValue('visit_date') || myValue < useFieldValue('visit_date')",
);
});
});