Reputation: 53
I am trying to test SetRole function which is calling GetRole function in the end, but I am unable to cover the line in code coverage. Please guide me related to testing cascaded function, nested function, function in the function.
component.ts
SetRole(inp){
this.role = inp;
this.GetRole()
}
Upvotes: 3
Views: 2093
Reputation: 761
Try this:
it('SetRole',() => {
const inp = 'dummyInput';
const spy = spyOn(component,'GetRole')
component.SetRole(inp)
expect(spy).toHaveBeenCalled()
});
Upvotes: 2