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

How to test reducers #7

Open
eguneys opened this issue Jul 26, 2015 · 1 comment
Open

How to test reducers #7

eguneys opened this issue Jul 26, 2015 · 1 comment

Comments

@eguneys
Copy link

eguneys commented Jul 26, 2015

I have setup an redux application using this repo as an example. I have two reducers gamePlay and saveStore.

gamePlay store is a regular store using some state.
saveStore store is a special store for saving properties on other stores and later restoring them.

In order for this to work, I make use of actions. Here's the gist of my application: https://gist.github.com/eguneys/a12bbe3b3e33254b3af2.

I have two questions:

  1. Is it a good idea to use stores/actions this way?
  2. How can I test the combined stores along with actions using middleware, that is whole redux application.

There are some examples here: https://github.com/gaearon/redux/pull/278/files#diff-755395ebcb422a6745dd7de738db93dbR1, but I couldn't figure out how to do it.

@quangbuule
Copy link
Owner

Here is my quick reply:

  1. That is ok, but you can use immutable.js to snapshot some of state of your application, this is better.
  2. Check out the redux 1.0.0RC (my example for that version: https://github.com/quangbuule/redux-example/tree/redux%40v1.0.0-rc)

The whole application now is just one store (each store in your mind now is one of store's properties)
Then, if you want to test, just dispatch an action, and do assert on your only store.

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