// Should call
it('Should call myFunc', () => {
const spiedFunction = spyOn<any>(component, 'myFunc');
component.myMethod();
expect(spiedFunction).toHaveBeenCalled();
});
// Should not call
it('Should not call myFunc', () => {
const spiedFunction = spyOn<any>(component, 'myFunc');
component.myMethod();
expect(spiedFunction).not.toHaveBeenCalled();
});
import * as dateHelper from './date.helper';
it('Should call dayIsValid', () => {
const spiedFunction = spyOn<any>(
dateHelper,
'isValid'
).and.returnValue({});
component.myMethod();
expect(spiedFunction).toHaveBeenCalled();
});
it('Should call myFunc', () => {
const spiedFunction = spyOn<any>(component, 'myFunc');
component.myMethod();
expect(spiedFunction).toHaveBeenCalled();
});