我的准则
addTodo: {
reducer: (state: State, action: { payload: Record<string, string>; type: string }) => {
state.todoMessage = action.payload.todoMessage;
state.id = action.payload.id;
state.completed = action.payload.completed;
},
prepare: (todoMessage: string) => {
return {
payload: { message: todoMessage, id: uuid(), completed: false }
};
}
},
我的Unit Test:
const action = {
type: addTodo.type,
payload: {
message: 'buy milk',
id: 'id',
completed: false,
},
};
const state = productDetailsReducer(reducerState, action);
expect(state.todoMessage).toEqual('buy milk');
expect(state.id).toEqual('id');
expect(state.completed).toBeFalsy();
我的问题是伊斯坦布尔显示prepare
功能不包括在内。你知道怎么掩盖吗?先谢了
尝试搜索redux工具包文档,找不到任何相关内容
1条答案
按热度按时间vxbzzdmp1#
您应该在单元测试中调用
addTodo
操作,以便覆盖其代码。模拟uuid
返回行列式id值。示例: