Testing Redux Combined Gearboxes

Let's say I have several gear functions and I combine them into one gear using combineReducers(...) , is there any way to check which gears actually contain a combined gear?

For example, if I have this:

 import { combineReducers } from 'redux' const reducer1 = (state, action) => {...} ... (more reducers, etc) const rootReducer = combineReducers({ reducer1, reducer2, reducer3 }) export default rootReducer 

Can I write a test with Mocha and Expect.js that will let me check if rootReducer reducer2 ? Is it possible?

The way I am currently configured for my project is that each reducer is in a separate file and then imported into a file where the combineReducers(...) function is used to combine them. I am testing all individual gearboxes to verify that they are doing what they should, but I also thought it would be nice to check the combined gearbox to make sure that it contains all the other gearboxes that it should (in case I forget add one example).

thanks

+5
source share
1 answer

You are testing the wrong thing IMO. You must believe that the combineReducers() function does what it should (it should be tested in Redux distribution tests). But you can create a method that will return an object with reducers to combine as the combineReducers() parameter. This method can and should be tested.

+4
source

Source: https://habr.com/ru/post/1244442/


All Articles