From 49d0ce6918543644b8e27df7dfd2c851c18b94e6 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 7 Sep 2016 13:12:55 +0200 Subject: [PATCH] export types of redux-mock-store (#10933) Within a test you sometimes want to declare the store first and then assign it the result of mockStore(state) in a beforeEach(). For that we need to export IStore. --- redux-mock-store/redux-mock-store-tests.ts | 9 +++++---- redux-mock-store/redux-mock-store.d.ts | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/redux-mock-store/redux-mock-store-tests.ts b/redux-mock-store/redux-mock-store-tests.ts index 4a6045c288..960591f8fb 100644 --- a/redux-mock-store/redux-mock-store-tests.ts +++ b/redux-mock-store/redux-mock-store-tests.ts @@ -1,6 +1,6 @@ /// -import configureStore from 'redux-mock-store'; +import configureStore, {IStore} from 'redux-mock-store'; // Redux store API tests // The following test are taken from ../redux/redux-tests.ts @@ -25,10 +25,11 @@ function loggingMiddleware() { }; } -const storeMock = configureStore([loggingMiddleware]); +const storeMock = configureStore([loggingMiddleware]); const initialState = 0 -let store = storeMock(initialState); +let store: IStore; +store = storeMock(initialState); store.subscribe(() => { // ... @@ -40,4 +41,4 @@ store.dispatch({ type: 'INCREMENT' }); // Additional mock store API tests var actions: Array = store.getActions(); -store.clearActions(); \ No newline at end of file +store.clearActions(); diff --git a/redux-mock-store/redux-mock-store.d.ts b/redux-mock-store/redux-mock-store.d.ts index 770603826a..6cc463e2d1 100644 --- a/redux-mock-store/redux-mock-store.d.ts +++ b/redux-mock-store/redux-mock-store.d.ts @@ -10,9 +10,9 @@ declare module 'redux-mock-store' { function createMockStore(middlewares?:Redux.Middleware[]):mockStore - type mockStore = (state?:T) => IStore; + export type mockStore = (state?:T) => IStore; - type IStore = { + export type IStore = { dispatch(action: any):any getState():T getActions():Object[] @@ -21,4 +21,4 @@ declare module 'redux-mock-store' { } export default createMockStore -} \ No newline at end of file +}