Я использую Redx-сагу с машинописью.В следующем, как мне издеваться над третьим параметром в runaga ()?
await runSaga(fakeStore, fetchAuthenticationSaga, authenticateRequestStartedAction(credentials));
done();
export interface IUserProfileAuthenticateAction extends Action {
userProfile?: ILoginResponse;
message?: string;
sendingRequest: boolean;
credentials?: ILogInEntity;
}
export const authenticateRequestStartedAction = (
credentials: ILogInEntity
): IUserProfileAuthenticateAction => {
return {
'credentials': credentials,
sendingRequest: true,
type: actionTypes.AUTHENTICATE_REQUEST
};
};
По сути, я не хочу вызывать реальное действие, а сейчас онозовет настоящую сагу.
test("should test authenticate success", async done => {
const dispatchedActions = [{}];
const resultStub = {
succeeded: true,
userProfile: {
id: 10,
name: "fixtureUser"
}
};
const spy = jest.spyOn(api, "callApi");
spy.mockImplementation(() => Promise.resolve(resultStub));
const fakeStore = {
dispatch: (action: IUserProfileAuthenticateAction) =>
dispatchedActions.push(action)
};
const credentials:ILogInEntity={
login:'test',
password:'password'
}
await runSaga(fakeStore, fetchAuthenticationSaga, authenticateRequestStartedAction(credentials));
done();
expect(spy.mock.calls.length).toBe(1);
expect(dispatchedActions).toContainEqual(authenticateSuccess(resultStub));
}, 10000);