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):Adding some test coverage for form-helper functions #332

Merged
merged 3 commits into from
Jul 4, 2024

Conversation

gitcliff
Copy link
Contributor

@gitcliff gitcliff commented Jun 27, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

PR is adding test coverage for some form helper functions

Screenshots

Related Issue

Other

it('should parse valid date string with time correctly', () => {
const dateString = '2023-06-27T14:30:00';
const expectedDate = new Date(2023, 5, 27, 14, 30, 0);
const parsedDate = parseToLocalDateTime(dateString);
Copy link
Contributor

Choose a reason for hiding this comment

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

@samuelmale why aren't we using parseDate?

Copy link
Member

Choose a reason for hiding this comment

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

No good reason! I agree we should rely more on the utils exposed by the framework.

Comment on lines 474 to 487

test('works with different patient data', () => {
patient = { id: 'patient2', name: 'Jane Doe' };
mockExpressionRunnerFn.mockReturnValue(false);
const result = evaluateDisabled(node, allFields, allValues, sessionMode, patient, mockExpressionRunnerFn);
expect(result).toBe(false);
expect(mockExpressionRunnerFn).toHaveBeenCalledWith(
node.value.disabled.disableWhenExpression,
node,
allFields,
allValues,
{ mode: sessionMode, patient },
);
});
Copy link
Contributor

@brandones brandones Jul 3, 2024

Choose a reason for hiding this comment

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

I cannot imagine what could cause this test to fail. Why is this a useful test?

Suggested change
test('works with different patient data', () => {
patient = { id: 'patient2', name: 'Jane Doe' };
mockExpressionRunnerFn.mockReturnValue(false);
const result = evaluateDisabled(node, allFields, allValues, sessionMode, patient, mockExpressionRunnerFn);
expect(result).toBe(false);
expect(mockExpressionRunnerFn).toHaveBeenCalledWith(
node.value.disabled.disableWhenExpression,
node,
allFields,
allValues,
{ mode: sessionMode, patient },
);
});

Copy link
Member

Choose a reason for hiding this comment

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

Deleted

Copy link
Contributor

@brandones brandones left a comment

Choose a reason for hiding this comment

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

Just the one question @gitcliff , otherwise LGTM. Please answer the question (or delete the test) and then we'll merge this in.

I'm not well-positioned to evaluate whether these are actually useful tests, or whether it is too much "testing implementation details." I will leave that evaluation to @samuelmale and @pirupius .

@pirupius pirupius merged commit 4af1702 into openmrs:main Jul 4, 2024
4 checks passed
Art-Ndiema pushed a commit to Art-Ndiema/openmrs-form-engine-lib that referenced this pull request Aug 8, 2024
* (test):Adding some test coverage for form-helper functions

* Update src/utils/form-helper.test.ts

* deletes unecessary test

---------

Co-authored-by: Brandon Istenes <brandonesbox@gmail.com>
Co-authored-by: Pius Rubangakene <piruville@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants