-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @ice/store Unit Test #84
Conversation
reviewed |
我在这个PR中已经更新了
不过这里面的PR还没有出来。应该是这个 .yml 文件没有更新到 master 分支上。具体如下面的链接 |
index.spec.ts 的测试挺全面。 这里提两个问题:
举个例子。测试 effect state,当前的实现是编写了用例 "get model effects state"。 我们是否可以:
可以对比一下这个思路和当前的做法间有哪些优缺点。 |
第二轮 reviewed |
tests/helpers/todos.ts
Outdated
@@ -29,15 +29,15 @@ const todos = { | |||
}, | |||
|
|||
effects: (dispatch) => ({ | |||
add({ todo, currentLength }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add(todo, rootState, { store }) {
this.addTodo(todo);
dispatch.user.setTodos(store.getModelState('todos').dataSource.length + 1);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
注意 rootState 是一个不可变数据,this.addTodo 后,rootState 不会发生变化。
tests/index.spec.tsx
Outdated
index: 0, | ||
currentLength: result.current.state.dataSource.length, | ||
}); | ||
result.current.dispatchers.delete(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result.current.dispatchers.delete(0, { store });
* chore: new version * fix: add meta type in ModelEffects (#102) * Add @ice/store Unit Test (#84) * chore: add dependency * test: add helper and init test * test: add createStore test * test: add withModel withModelActions withModelEffectsState test * test: add throw error when getting unexist model * chore: new version * test: add global actions test * test: add createModel test * test: add createUseContainer test * chore: createModel * test: add createContainer test * test: update test cases * test: add useModel test * test: add class component test * test: update class component test * test: add createStore options test * test: add appendReducer test * test: add appendReducer test * chore: lint * test: add utils test * docs: add badge * chore: remove unnecessary comment * test: update converter test * feat: add comment to pr * fix: fix by the comments * chore: update codecov config * test: update test * test: update converter test case * test: update examples * test: update todos example * chore: update modelEffects type Co-authored-by: alvinhui <alvin.hui@qq.com> * fix: effects should return an object (#105) * fix: effects should return an object * chore: lint * Better example (#106) * chore: add classComponent example * chore: rename async function * chore: visibility logic * docs: add examples section * feat: withModel (#104) * feat: withModel init * refactor: model apis * feat: model for withModel * feat: ts support for withModel * chore: typo * chore: lint * test: disable loading and error * test: mock value * chore: playload && meta is option * chore: typo * docs: withModel * refactor: class and function component demo * chore: class component support * chore: remove console * chore: lint * chore: withModel example * chore: remove product * chore: undo * chore: typo * Docs: Migrating From Redux (#108) * chore: example @ice/store version Co-authored-by: Hengchang Lu <44047106+luhc228@users.noreply.github.com>
增加 @ice/store单元测试(基于 icestore 1.3.x 版本)
Utils
Basic API