Skip to content

Commit

Permalink
feat(store): cleanup selector after a test
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored and brandonroberts committed Sep 24, 2019
1 parent 88ebdde commit 2964e2b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/store/testing/src/mock_store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Inject, Injectable } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { Observable, BehaviorSubject } from 'rxjs';
import {
Action,
Expand All @@ -14,6 +15,17 @@ import { MockState } from './mock_state';
import { MockSelector } from './mock_selector';
import { MOCK_SELECTORS } from './tokens';

if (typeof afterEach === 'function') {
afterEach(() => {
try {
const store = TestBed.get(Store) as MockStore<any>;
if (store && 'resetSelectors' in store) {
store.resetSelectors();
}
} catch {}
});
}

@Injectable()
export class MockStore<T> extends Store<T> {
static selectors = new Map<
Expand Down

0 comments on commit 2964e2b

Please sign in to comment.