-
Notifications
You must be signed in to change notification settings - Fork 18
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
How to mock store in components #14
Comments
This is how I did it but I'm really not confortable with, if you have a better way please let us know :). Love Statex man!! Implementation:
Unit test:
|
@blopez2010, give me couple of hours. I will upload a test case for list component |
@blopez2010, StateX is configured for detached store and view. Therefore when you unit test a view you must only test for appropriate actions being dispatched. What happens when an action is trigged must be tested under store's test case, not here. This example should help you understand how to test that. https://github.com/rintoj/statex/blob/master/examples/todo-ng-ts/src/app/list/list.component.spec.ts |
Thanks @rintoj for the example! |
I have some problems with the example above. What I forgot is to reset the state before each test: an other possibility is the jasmin spy returns a correct state. example: |
I've being looking around how to mock components in order to be tested, do you have an idea? https://github.com/rintoj/statex/blob/master/examples/todo-ng-ts/src/app/list/list.component.ts
Since you are doing a
new
instance of the store, it isn't quite easy to test it.Thanks!
The text was updated successfully, but these errors were encountered: