UNPKG

1.3 kBTypeScriptView Raw
1// Type definitions for Redux Mock Store 1.0.2
2// Project: https://github.com/dmitry-zaets/redux-mock-store
3// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.3
6
7import * as Redux from 'redux';
8
9export interface MockStore<S = any, A extends Redux.Action = Redux.AnyAction> extends Redux.Store<S, A> {
10 getActions(): any[];
11 clearActions(): void;
12}
13
14export type MockStoreEnhanced<S = {}, DispatchExts = {}> = MockStore<S> & {dispatch: DispatchExts};
15
16export type MockStoreCreator<S = {}, DispatchExts = {}> = (state?: S | MockGetState<S>) => MockStoreEnhanced<S, DispatchExts>;
17
18export type MockGetState<S = {}> = (actions: Redux.AnyAction[]) => S;
19
20/**
21 * Create Mock Store returns a function that will create a mock store from a state
22 * with the same set of set of middleware applied.
23 *
24 * @param middlewares The list of middleware to be applied.
25 * @template S The type of state to be held by the store.
26 * @template DispatchExts The additional Dispatch signatures for the middlewares applied.
27 */
28declare function createMockStore<S, DispatchExts = {}>(middlewares?: Redux.Middleware[]): MockStoreCreator<S, DispatchExts>;
29
30export default createMockStore;