Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(test) O3-3939: Add test to repeat component #385

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/repeat/repeat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ describe('RepeatingFieldComponent - handleExpressionFieldIdUpdate', () => {
"myValue > today() || myValue <= '1/1/1890' || myValue > useFieldValue('visit_date') || myValue < useFieldValue('visit_date')",
);
});

it('Should update field ID in expressions when adding repeated fields', () => {
const expression = "infantStatus !== 'someValue'";
const fieldIds = ['birthDate', 'infantStatus', 'deathDate'];
const updatedExpression = updateFieldIdInExpression(expression, 2, fieldIds);

expect(updatedExpression).toEqual("infantStatus_2 !== 'someValue'");
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WodPachua I like the test but the scope of work begs for testing the repeat component itself and not just the helpers. You want to render a form with a "repeatable" field, and then test out things like:

  1. Asserting that clicking the "Add" button clones the field at origin
  2. Test out submission (Assert that both the origin and its instances' values are submitted successfully)
  3. Edit mode (Assert that a repeat field with instances is properly initialised (hydrated) as expected)

});
Loading