Skip to content

Commit

Permalink
feat(store): more tests
Browse files Browse the repository at this point in the history
Closes ngrx#2363
  • Loading branch information
evgenyfedorenko committed May 10, 2020
1 parent 09d57ad commit 4bcddb4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions modules/store/testing/spec/mock_store.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { skip, take, tap } from 'rxjs/operators';
import { skip, take } from 'rxjs/operators';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import {
Store,
Expand All @@ -10,10 +10,12 @@ import {
createFeatureSelector,
} from '@ngrx/store';
import { INCREMENT } from '../../spec/fixtures/counter';
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { By } from '@angular/platform-browser';

import * as store from '@ngrx/store';

interface TestAppSchema {
counter1: number;
counter2: number;
Expand All @@ -40,6 +42,8 @@ describe('Mock Store', () => {
);

beforeEach(() => {
spyOn(store, 'setNgrxMockEnvironment').and.callThrough();

TestBed.configureTestingModule({
providers: [
provideMockStore({
Expand All @@ -63,10 +67,15 @@ describe('Mock Store', () => {
mockStore.resetSelectors();
});

it('should set NgrxMockEnvironment', () => {
expect(store.setNgrxMockEnvironment).toHaveBeenCalledWith(true);
});

it('should provide the same instance with Store and MockStore', () => {
const fromStore = TestBed.inject(Store);
const fromMockStore = TestBed.inject(MockStore);
expect(fromStore).toBe(fromMockStore);
expect(store.setNgrxMockEnvironment).toHaveBeenCalled();
});

it('should set the initial state to a mocked one', (done: any) => {
Expand Down

0 comments on commit 4bcddb4

Please sign in to comment.