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

Unit test examples #11

Open
Nxt3 opened this issue Jan 25, 2018 · 4 comments
Open

Unit test examples #11

Nxt3 opened this issue Jan 25, 2018 · 4 comments

Comments

@Nxt3
Copy link

Nxt3 commented Jan 25, 2018

Would it be possible to see todo-ng-ts with some unit testing? I'd be interested to see how statex can improve unit testing.

@Nxt3
Copy link
Author

Nxt3 commented Feb 7, 2018

@rintoj Is there any way we could get a basic example on how to perform testing the state with Angular + Karma/Jasmine? Without such documentation or examples, my team is probably going to have to use another library. Testing is important.

@rintoj
Copy link
Owner

rintoj commented Feb 8, 2018

Here is an example to show how to test StateX store. Hope this helps.

https://github.com/rintoj/statex/blob/master/examples/todo-ng-ts/src/store/todo-store.spec.ts

@Nxt3
Copy link
Author

Nxt3 commented Feb 8, 2018

@rintoj What about testing a component with a store (i.e. testing values in the store are set after certain functions are called)? Or am I thinking about that incorrectly?

@rintoj
Copy link
Owner

rintoj commented Feb 12, 2018

Hi @Nxt3, sorry for the delay.

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

And if you would like to test state mapping to the component State.next() can be used.

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

No branches or pull requests

2 participants