简体   繁体   English

测试Redux中选择器的过滤状态

[英]Testing for filtering state of selectors in Redux

An example of the code is here: https://codesandbox.io/s/8zomm846v9 代码示例在这里: https : //codesandbox.io/s/8zomm846v9

I'm writing a test for selectors.js . 我正在为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. 据我了解,当makeSelectYears() ,它将执行selectYearsDomain()并仅返回年份。 It will then return the filtered data as a JSON object. 然后,它将过滤后的数据作为JSON对象返回。

However, makeSelectYears().resultFunc(fixture) returns the entire JSON without the filter. 但是, makeSelectYears().resultFunc(fixture)返回不带过滤器的整个JSON。 I have the output commented in the above link. 我在上面的链接中评论了输出。

I'm not able to modify selectors.js in any way, only add testing. 我无法以任何方式修改selectors.js ,只能添加测试。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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