@angular-redux/store
Version:
Angular 2 bindings for Redux
54 lines (53 loc) • 2.55 kB
TypeScript
import { NgRedux, Selector, Comparator, PathSelector } from '@angular-redux/store';
import { Reducer, Dispatch, Middleware, Store, StoreEnhancer } from 'redux';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/observable/from';
import 'rxjs/add/operator/distinctUntilChanged';
import { MockObservableStore } from './observable-store.mock';
/**
* Convenience mock to make it easier to control selector
* behaviour in unit tests.
*/
export declare class MockNgRedux extends NgRedux<any> {
/** @deprecated Use MockNgRedux.getInstance() instead. */
static mockInstance?: MockNgRedux;
private mockRootStore;
/**
* Returns a subject that's connected to any observable returned by the
* given selector. You can use this subject to pump values into your
* components or services under test; when they call .select or @select
* in the context of a unit test, MockNgRedux will give them the values
* you pushed onto your stub.
*/
static getSelectorStub<R, S>(selector?: Selector<R, S>, comparator?: Comparator): Subject<S>;
/**
* Returns a mock substore that allows you to set up selectorStubs for
* any 'fractal' stores your app creates with NgRedux.configureSubStore.
*
* If your app creates deeply nested substores from other substores,
* pass the chain of pathSelectors in as ordered arguments to mock
* the nested substores out.
* @param pathSelectors
*/
static getSubStore<S>(...pathSelectors: PathSelector[]): MockObservableStore<S>;
/**
* Reset all previously configured stubs.
*/
static reset(): void;
/**
* Gets the singleton MockNgRedux instance. Useful for cases where your
* tests need to spy on store methods, for example.
*/
static getInstance(): MockNgRedux;
provideStore: (store: Store<any>) => void;
configureStore: (rootReducer: Reducer<any>, initState: any, middleware?: Middleware[] | undefined, enhancers?: StoreEnhancer<any>[] | undefined) => void;
configureSubStore: <SubState>(basePath: (string | number)[], localReducer: Reducer<SubState>) => MockObservableStore<SubState>;
select: <SelectedState>(selector?: string | number | symbol | (string | number)[] | ((s: any) => SelectedState) | undefined, comparator?: Comparator | undefined) => Observable<any>;
dispatch: Dispatch<any>;
getState: () => null;
subscribe: () => () => null;
replaceReducer: () => null;
/** @hidden */
private constructor();
}