In my Component
@Input('price')
set setPrice(price) {
this.price = price;
this.modifyTotalAmount();
}
test (component.spec.ts)
it('should call function ', () => {
spyOn(fixture.componentInstance, 'modifyTotalAmount');
fixture.componentInstance.price = 4500;
fixture.detectChanges();
const divActualPrice = fixture.debugElement.query(By.css('#actualPrice'));
expect(divActualPrice.componentInstance.modifyTotalAmount).toHaveBeenCalled();
});
Normally when parent compoent value get changed this setPrice(price) hits and modifyTotalAmount() function called. But when unit test runs that modifyTotalAmount() not called. this test case get faild. I think what I have done in test case could be wrong. can anyone please clarify whats wrong with this.