【发布时间】:2021-04-27 15:16:22
【问题描述】:
这是我previous question的延续。
我尝试测试 REGISTER_FAIL 案例。这就是我所做的:
test("should not register a user", async () => {
axios.mockRejectedValue({
status: 500,
});
const userInfo = {
name: "",
email: "",
password: "",
};
await store.dispatch(register(userInfo)).then(() => {
expect(store.getActions()[0]).toEqual({
type: REGISTER_FAIL,
payload: {
token: null,
isAuthenticated: false,
loading: true,
// user: null,
},
});
});
});
【问题讨论】: