Я пытаюсь шпионить за функцией компонента. Я могу это шпионить, но мой тестовый код не вызывает установщик ввода этого компонента.
export class CameraComponent implements OnInit {
liveData: LiveDataModal[];
@Input('liveData')
set setLiveData(data: LiveDataModal[]) {
this.liveData = data;
this.renderCanvas();
}
renderCanvas() {
// ...
}
}
describe('CameraComponent', () => {
it('should re render', () => {
const fixture = TestBed.createComponent(CameraComponent);
const component = fixture.componentInstance;
fixture.detectChanges();
expect(component).toBeTruthy();
const renderCanvasSpy = spyOn(component, 'renderCanvas')
component.liveData = [];
component.renderCanvas();
fixture.detectChanges();
const invokeCount = renderCanvasSpy.calls.count();
expect(invokeCount).toEqual(2)
// invokeCount should be to 2 but its 1
});
})