UNPKG

jest-mock-action-creators

Version:

Easy mock & test redux action creators with dispatch() in your components

38 lines (37 loc) 1.27 kB
export interface ActionCreatorInvokation { /** * Action creator function name */ actionCreator: string; /** * Action creator arguments */ args?: any[]; } /** * Auto-Mock given action creators to use them with expect(dispatch).tobeCalledWithActionCreator() * @param actionCreators */ export declare function mockActionCreators(...actionCreators: Array<Function | { [key: string]: Function; }>): void; /** * Replace mocked action creators to use them with expect(dispatch).toBeCalledWithActionCreator() * Doesn't automock them (if using babel plugin) so they should be mocked before */ export declare const replaceActionCreators: typeof mockActionCreators; /** * Create dispatch implementation with given expectations * @param dispatch Mocked dispatch function * @param expectations Expectations object. Key is the action creator function name, value is the result */ export declare function createDispatchMockImplementation(dispatch: Function, expectations: { [key: string]: any; }, logWithoutExpectation?: boolean): void; declare global { namespace jest { interface Matchers<R> { toBeCalledWithActionCreator(actionCreatorName: string | Function, ...args: any[]): void; } } }