3

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()
}

1 Answers1

2

Try this:

    it('SetRole',() => {
    
    const inp = 'dummyInput';
    const spy = spyOn(component,'GetRole')
    component.SetRole(inp)
    
    expect(spy).toHaveBeenCalled()
});
Kartik Dolas
  • 703
  • 1
  • 9
  • 24