-
Notifications
You must be signed in to change notification settings - Fork 0
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: add and use util to inject one metadata manager #893
test: add and use util to inject one metadata manager #893
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @davidlj95 and the rest of your teammates on |
e1e8e71
to
67254c6
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
=======================================
Coverage 99.46% 99.46%
=======================================
Files 79 79
Lines 372 372
Branches 73 73
=======================================
Hits 370 370
Partials 2 2 ☔ View full report in Codecov by Sentry. |
📦 Bundle size (Angular v17)Git ref:
|
📦 Bundle size (Angular v18)Git ref:
|
📦 Bundle size (Angular v16)Git ref:
|
📦 Bundle size (Angular v15)Git ref:
|
67254c6
to
d6723b8
Compare
🎉 This PR is included in version 1.0.0-beta.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Issue or need
A trick is used right now for existing metadata manager tests in order to unit test the metadata manager (its setter, actually).
This is done because metadata managers are provided as part of a
multi
provider for theNgxMetaMetadataManager
token / abstract class.So can't inject one specifically.
The trick has been to export the setter factory (that comes with dependencies as arguments). Then, when unit testing, manually inject the needed dependencies.
This is not ideal because it doesn't reflect real use (where automatic injection is done).
And now is an impediment for a subsequent refactor removing the
deps
usage by calls toinject
in the factory. Then, a way is needed to unit test metadata managers without manually injecting. As otherwise, an error will appear about usinginject
in a non-injection context.Proposed changes
Introduce
injectOneMetadataManager
util for tests. Which will inject the only metadata manager existing. Or throw otherwise.injectMetadataManagers
has been internally exported in order to use it for that util too.Then, use that util around to avoid the trick.
Other changes: unite
undefined
/null
test cases in a describe + for loop.Quick reminders