Closed luhc228 closed 4 years ago
createContainer.tsx 里面的方法createContainer需要传参useValue.
这个 useValue 应该可以是任意的 hooks , 不一定需要 createModel 里的 useValue?
createContainer.tsx 里面的方法createContainer需要传参useValue.
这个 useValue 应该可以是任意的 hooks , 不一定需要 createModel 里的 useValue?
useValue是任意的hooks 我的理解是 如果是任意的hooks的话,没办法拿到他的值呢?后面就没法测试到Provider?比如下面的 const value = useValue(props);
应该要拿到value吧
@luhc228 这个 PR 非常的出色! 但我们在在 1.3.0 中重构了 icestore https://github.com/ice-lab/icestore/pull/82 ,如果可以的话,是不是可以基于这个 PR 为 1.3.0 版本补充单测?可以将 PR 的目标分支指向 master。
增加 @ice/store单元测试
0. add some examples for test
1. createStore Module
2. createModel Module
3. createContainer
补充:
withModelActionsState
&useModelActionsState
没有做相应的测试,看代码上注释着@deprecated,只分别对应测试withModelEffectsState
&useModelEffectsState
createContainer.tsx
里面的方法createContainer
需要传参useValue
。而useValue
是在模块createModel
中的方法,useValue
没有从模块中导出。 解决方法:在src
目录下新建__mocks__
文件夹,并新建createModel.tsx
,这个文件是/src/createModel.tsx
的mock方法,返回的值只有useValue
,便于测试createContainer
功能。 参考:https://jestjs.io/docs/zh-Hans/manual-mocks