[ ] PR title descriptive (can be used in release notes)
TODO
[x] Builds on top of #2127, should update post merge
[x] 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
PR Checklist
TODO
Description
Add
TemplateCalcService
spec testsAdd additional mock services for templateCalcService dependencies
Refactor app data
constants.ts
to shareAPP_CONFIG
via a function instead of static import as this caused issues within test environments (likely because tests don't have access todata-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