@jedmao/redux-mock-store
Version:
A mock store for testing your redux async action creators and middleware
16 lines (15 loc) • 1.05 kB
TypeScript
import { Action, AnyAction, DeepPartial, Middleware, Store, Unsubscribe } from 'redux';
/**
* A mock store for testing Redux async action creators and middleware.
*/
export declare function configureMockStore<S = any, A extends Action = AnyAction, DispatchExts extends {} | void = void>(middlewares?: Middleware[]): MockStoreCreator<S, A, DispatchExts>;
export declare type MockStoreCreator<S = {}, A extends Action = AnyAction, DispatchExts extends {} | void = void> = (state?: DeepPartial<S> | MockGetState<DeepPartial<S>>) => DispatchExts extends void ? MockStore<S, A> : MockStoreEnhanced<S, A, DispatchExts>;
export declare type MockGetState<S = {}> = (actions: AnyAction[]) => S;
export declare type MockStoreEnhanced<S, A extends Action = AnyAction, DispatchExts = {}> = MockStore<DeepPartial<S>, A> & {
dispatch: DispatchExts;
};
export interface MockStore<S = any, A extends Action = AnyAction> extends Store<DeepPartial<S>, A> {
clearActions(): void;
getActions(): A[];
subscribe(listener: (action: A) => void): Unsubscribe;
}