I do have the following beforeEach
:
beforeEach(() => {
fixture = TestBed.createComponent(ApplyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
store = TestBed.get<Store<fromAnnouncement.AnnouncementState>>(Store);
store.refreshState();
mockApplicationSelector = store.overrideSelector(selectDraftApplication, testDraftApplication); <-- Try to mock a selector here.
});
The selector selectDraftApplication depends on the feature selector for the AnnouncementState
, which has two entities in it, one of which im subselecting with a feature selector in order to build my selectDraftApplication
selector.
When using this code in test, all my tests crash, because NgRx somehow still seems to look for all the state further up, when I would expect a mock to be something that prevents precisely this. There is no point in mocking out a whole ngrx entity store, so I would just like the selector to return exactly that object and be done with it. I googled wide and far, but did not get any answer. Any help? I run Angular 8 and ngrx 8.5.1 (the refreshState()
function did not work either...)
Thanks!
EDIT:
export const getAnnouncementState = createFeatureSelector<AnnouncementState>('announcement');
export const getApplicationsState = createSelector(
getAnnouncementState,
(state: AnnouncementState) => state.applications
);
export const selectDraftApplication = createSelector(
getApplicationsState,
(state: ApplicationState) => state.draftApplication
);