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.
This commit is contained in:
Hendrik Liebau
2016-09-07 13:12:55 +02:00
committed by Masahiro Wakame
parent 13322c67cc
commit 49d0ce6918
2 changed files with 8 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
/// <reference path="./redux-mock-store.d.ts" />
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<number>([loggingMiddleware]);
const initialState = 0
let store = storeMock(initialState);
let store: IStore<number>;
store = storeMock(initialState);
store.subscribe(() => {
// ...
@@ -40,4 +41,4 @@ store.dispatch({ type: 'INCREMENT' });
// Additional mock store API tests
var actions: Array<any> = store.getActions();
store.clearActions();
store.clearActions();

View File

@@ -10,9 +10,9 @@ declare module 'redux-mock-store' {
function createMockStore<T>(middlewares?:Redux.Middleware[]):mockStore<T>
type mockStore<T> = (state?:T) => IStore<T>;
export type mockStore<T> = (state?:T) => IStore<T>;
type IStore<T> = {
export type IStore<T> = {
dispatch(action: any):any
getState():T
getActions():Object[]
@@ -21,4 +21,4 @@ declare module 'redux-mock-store' {
}
export default createMockStore
}
}