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: template calc specs #2130

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Test: template calc specs #2130

wants to merge 3 commits into from

Conversation

chrismclarke
Copy link
Member

@chrismclarke chrismclarke commented Nov 5, 2023

PR Checklist

  • PR title descriptive (can be used in release notes)

TODO

  • Builds on top of Feat/plh calc functions #2127, should update post merge
  • Minor conflict likely due to moving core calc functions
  • Should also add minimal spec tests for core calc functions
  • Add spec for window functions
  • Consider updating documentation

Description

  • Add TemplateCalcService spec tests

  • Add additional mock services for templateCalcService dependencies

  • Refactor app data constants.ts to share APP_CONFIG via a function instead of static import as this caused issues within test environments (likely because tests don't have access to data-models by default). Whilst it is possible to setup helpers to handle this type of case, felt easier to just call on demand as none of the tests created require the config (just contain other dependencies that reference the file in method, forcing the invocation of the static export).

Initially I had hoped to setup a testing environment that would allow testing the plh_calc functions called from a templating context (e.g. @calc(plh_add_family_member(@local.families)), however I realised the current system isn't set up very well to support. I've added issue #2131 to suggest ways we might want to reconsider the calc system in the future.

So for now this PR only adds some simple spec tests and does not provide any more advanced e2e testing

Review Notes

yarn ng test --include src\app\shared\components\template\services\template-calc.spec.ts

Dev Notes

As discussed in recent conversations linked to #2080, this provides another example of using mocked services when testing methods of a service with dependencies (in case of interest). The mocks are quite minimal, and could be expanded as we add tests for other services that require additional functionality

Git Issues

Closes #

Screenshots/Videos

If useful, provide screenshot or capture to highlight main changes

@chrismclarke chrismclarke changed the title Test/template calc Test: template calc specs Nov 5, 2023
@chrismclarke chrismclarke mentioned this pull request Nov 5, 2023
1 task
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.

1 participant