I'm trying to test that a component calls detectChanges
on it's injected ChangeDetectorRef
I've stepped through the code and it's definitely called, but it appears I'm getting different values for the ChangeDetectorRef in the component and in the test. Here's the code. I've also tried the commented out spy, but it didn't work either.
it('should call ChangeDetectorRef.detectChanges from onFixedUpdate', () => {
let changeDetectorService = fixture.debugElement.injector.get(ChangeDetectorRef, null);
let spy = spyOn(changeDetectorService, 'detectChanges').and.callThrough();
//let spy = spyOn(fixture.changeDetectorRef, 'detectChanges').and.callThrough();
expect(spy).not.toHaveBeenCalled();
fixture.componentInstance.onFixedUpdate(1);
expect(spy).toHaveBeenCalled();
});