我在saga中有以下方法
export function* loadCustomerDetails(action) {
const customer = yield call(() => educationAPI.fetchCustomerDetails(action.id));
yield put(saveCustomerDetails(customer));
}
function* watchLoadCustomereDetails() {
yield takeLatest(actionTypes.LOAD_CUSTOMER_DETAILS, loadCustomerDetails);
}
export default function* root() {
yield fork(watchLoadCustomerDetails);
}
我写了以下测试用例
describe('loadCustomerDetails', () => {
const generator = cloneableGenerator(loadCustomerDetails)();
const customerDetails = {
items: undefined,
};
it('does nothing with no data', () => {
const clone = generator.clone();
expect(clone.next().value).toEqual(call(educationAPI.fetchCustomerDetails));
expect(clone.next(customerDetails).value).toEqual(put(saveCustomerDetails()));
expect(clone.next().done).toBe(true);
});
});
当我运行我的测试用例时,我收到错误:
Expected value to equal:
{"@@redux-saga/IO": true, "PUT": {"action": {"customerDetails": undefined, "type": "SAVE_CUSTOMER_DETAILS"}, "channel": null}}
Received:
{"@@redux-saga/IO": true, "CALL": {"args": [], "context": null, "fn": [Function anonymous]}}
为什么我的测试用例失败了?