UNPKG

1.02 kBTypeScriptView Raw
1import * as Redux from "redux";
2
3export interface MockStore<S = any, A extends Redux.Action = Redux.AnyAction> extends Redux.Store<S, A> {
4 getActions(): any[];
5 clearActions(): void;
6}
7
8export type MockStoreEnhanced<S = {}, DispatchExts = {}> = MockStore<S> & { dispatch: DispatchExts };
9
10export type MockStoreCreator<S = {}, DispatchExts = {}> = (
11 state?: S | MockGetState<S>,
12) => MockStoreEnhanced<S, DispatchExts>;
13
14export type MockGetState<S = {}> = (actions: Redux.AnyAction[]) => S;
15
16/**
17 * Create Mock Store returns a function that will create a mock store from a state
18 * with the same set of set of middleware applied.
19 *
20 * @param middlewares The list of middleware to be applied.
21 * @template S The type of state to be held by the store.
22 * @template DispatchExts The additional Dispatch signatures for the middlewares applied.
23 */
24declare function createMockStore<S, DispatchExts = {}>(
25 middlewares?: Redux.Middleware[],
26): MockStoreCreator<S, DispatchExts>;
27
28export default createMockStore;