mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-18 08:56:41 +00:00
test(reminders): move TestBed.inject after overrideProvider
Calling TestBed.inject(MockStore) in beforeEach instantiated the test module, so the subsequent TestBed.overrideProvider(MAT_DIALOG_DATA) in createComponent threw "Cannot override provider when the test module has already been instantiated" across all 7 destroy-cleanup specs. Move the store inject and dispatch spy into createComponent, after the override runs, so TestBed stays un-instantiated until the per-test MAT_DIALOG_DATA value is registered.
This commit is contained in:
parent
30550efa34
commit
9c7cb7c3eb
1 changed files with 5 additions and 3 deletions
|
|
@ -545,6 +545,11 @@ describe('DialogViewTaskRemindersComponent destroy clears unhandled deadline rem
|
|||
): DialogViewTaskRemindersComponent => {
|
||||
TestBed.overrideProvider(MAT_DIALOG_DATA, { useValue: { reminders } });
|
||||
taskServiceSpy.getByIdsLive$.and.returnValue(of(storeTasks));
|
||||
// TestBed becomes instantiated on the first inject/createComponent call,
|
||||
// after which overrideProvider throws. Resolve the store here — after the
|
||||
// override — rather than in beforeEach so the override still applies.
|
||||
store = TestBed.inject(MockStore);
|
||||
dispatchSpy = spyOn(store, 'dispatch').and.callThrough();
|
||||
const fixture = TestBed.createComponent(DialogViewTaskRemindersComponent);
|
||||
return fixture.componentInstance;
|
||||
};
|
||||
|
|
@ -587,9 +592,6 @@ describe('DialogViewTaskRemindersComponent destroy clears unhandled deadline rem
|
|||
TranslateStore,
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
store = TestBed.inject(MockStore);
|
||||
dispatchSpy = spyOn(store, 'dispatch').and.callThrough();
|
||||
});
|
||||
|
||||
it('dispatches clearDeadlineReminder on ngOnDestroy for an unhandled deadline reminder', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue