Testing Flux StoresThis section will walk through the process of testing the basic path of an action being dispatched to a store and the store emitting a change event.
Due to the design of Flux architecture stores can not be modified from the outside. Since they have no setters, only getters, the only way for data to get into the store is through the callback the store registered with the dispatcher. The way we test stores with Jest is that we use the testing framework to mock every module except the store that is being tested.
We Will Write a Custom Essay Specifically
For You For Only $13.90/page!
Before each test we have to simulate the Flux data flow. In order to do it first of all we need to get a reference to the `register()` function of our application’s dispatcher. The dispatcher is thoroughly mocked by Jest, testing framework does it automatically. This function is used by the store to register the