mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
Merge pull request #17081 from meandmax/update-redux-mock-store-interface
fix(reduxMockStore): mockStore should return intersection of ...
This commit is contained in:
Vendored
+6
-9
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Redux Mock Store v0.0.6
|
||||
// Type definitions for Redux Mock Store v0.0.7
|
||||
// Project: https://github.com/arnaudbenard/redux-mock-store
|
||||
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -6,19 +6,16 @@
|
||||
///<reference types="redux" />
|
||||
|
||||
declare module 'redux-mock-store' {
|
||||
import * as Redux from 'redux'
|
||||
import * as Redux from 'redux';
|
||||
|
||||
function createMockStore<T>(middlewares?: Redux.Middleware[]): mockStore<T>;
|
||||
|
||||
export type mockStore<T> = (state?: T) => IStore<T>;
|
||||
|
||||
export interface IStore<T> {
|
||||
dispatch(action: any): any;
|
||||
getState(): T;
|
||||
interface MockStore<T> extends Redux.Store<T> {
|
||||
getActions(): any[];
|
||||
clearActions(): void;
|
||||
subscribe(listener: Function): Function;
|
||||
}
|
||||
|
||||
export default createMockStore
|
||||
export type mockStore<T> = (state?: T) => MockStore<T>;
|
||||
|
||||
export default createMockStore;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"redux": "^3.6.0"
|
||||
"redux": "^3.6.0",
|
||||
"redux-mock-store": "^1.2.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Redux from 'redux';
|
||||
import configureStore, {IStore} from 'redux-mock-store';
|
||||
import configureStore from 'redux-mock-store';
|
||||
|
||||
// Redux store API tests
|
||||
// The following test are taken from ../redux/redux-tests.ts
|
||||
@@ -26,9 +26,8 @@ function loggingMiddleware() {
|
||||
|
||||
const storeMock = configureStore<number>([loggingMiddleware]);
|
||||
const initialState = 0
|
||||
let store: IStore<number>;
|
||||
|
||||
store = storeMock(initialState);
|
||||
const store = storeMock(initialState);
|
||||
|
||||
store.subscribe(() => {
|
||||
// ...
|
||||
@@ -44,4 +43,4 @@ store.clearActions();
|
||||
|
||||
// actions access without the need to cast
|
||||
var actions2 = store.getActions();
|
||||
actions2[10].payload.id;
|
||||
actions2[10].payload.id;
|
||||
|
||||
Reference in New Issue
Block a user