This is the public of @angular-redux2/store. It wraps the global redux store and adds a few other add-on methods. It's what you'll inject into your Angular application as a service.

Convenience mock to make it easier to control selector behaviour in unit tests.

Type Parameters

  • S = any

Hierarchy

Constructors

Properties

_store$: ReplaySubject<any> = ...

Angular subject store corresponds to store change event and trigger rxjs change event

selections: SelectorStubMap = {}

Mock selectors

subStores: SubStoreStubMap = {}

Mock substore

Methods

  • 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.

      it('select ticket price data from the substore', async(() => {
    const mockSubStore = MockNgRedux.getSubStore(
    ['WALLABIES', 'items', 'id1']);

    const selectorStub = mockSubStore.getSelectorStub('ticketPrice');
    selectorStub.next(2);
    selectorStub.complete();

    animalComponent.ticketPrice$
    .subscribe(
    ticketPrice => expect(ticketPrice).toEqual(2));
    }));

    Type Parameters

    • SelectedState

    Parameters

    Returns Subject<SelectedState>

  • 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 sub stores from another sub store, pass the chain of pathSelectors in as ordered arguments to mock the nested sub store out.


    it('select name data from the substore', async(() => {
    const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);

    const selectorStub = mockSubStore.getSelectorStub('name');
    selectorStub.next('Wilbert');
    selectorStub.complete();

    animalComponent.name$
    .subscribe(
    name => expect(name).toEqual('Wilbert'));
    }));

    Type Parameters

    • SubState

    Parameters

    Returns MockNgRedux<SubState>

  • Mock provideStore

    Accepts a Redux store, then sets it in NgRedux and allows NgRedux to observe and dispatch to it. This should only be called once for the lifetime of your app, for example, in the constructor of your root component.

    Parameters

    • _: any
    • __: Store<any, AnyAction>

    Returns void

  • 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.

      it('select ticket price data from the substore', async(() => {
    const mockSubStore = MockNgRedux.getSubStore(
    ['WALLABIES', 'items', 'id1']);

    const selectorStub = mockSubStore.getSelectorStub('ticketPrice');
    selectorStub.next(2);
    selectorStub.complete();

    animalComponent.ticketPrice$
    .subscribe(
    ticketPrice => expect(ticketPrice).toEqual(2));
    }));

    Type Parameters

    • R

    • S

    Parameters

    Returns 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 sub stores from another sub store, pass the chain of pathSelectors in as ordered arguments to mock the nested sub store out.


    it('select name data from the substore', async(() => {
    const mockSubStore = MockNgRedux.getSubStore(['WALLABIES', 'items', 'id1']);

    const selectorStub = mockSubStore.getSelectorStub('name');
    selectorStub.next('Wilbert');
    selectorStub.complete();

    animalComponent.name$
    .subscribe(
    name => expect(name).toEqual('Wilbert'));
    }));

    Type Parameters

    • S

    Parameters

    Returns MockNgRedux<S>

Generated using TypeDoc