简体   繁体   中英

Testing for filtering state of selectors in Redux

An example of the code is here: https://codesandbox.io/s/8zomm846v9

I'm writing a test for selectors.js . My fixture data is a section of the state being converted into an immutable map. From my understanding, as makeSelectYears() is called, it will execute selectYearsDomain() and return only the years. It will then return the filtered data as a JSON object.

However, makeSelectYears().resultFunc(fixture) returns the entire JSON without the filter. I have the output commented in the above link.

I'm not able to modify selectors.js in any way, only add testing. I'm not sure the best way to test the selector to ensure it's working as intended.

Any help would be appreciated.

Instead of calling

makeSelectYears().resultFunc(fixture)

you should call

makeSelectYears()(fixture)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM