I write a code for unit testing but it isn't worked. I wanna know how to use it and I am new to unit testing
COMPONENT.HTML
<button class="set-button" (click)="clickFunction()"> SAVE</button>
COMPONENT.TS
clickFunction(){
console.log('WORKED');
}
COMPONENT.SPECS.TS
it('function on button click ', () => {
spyOn(component, 'clickFunction');
let btn = fixture.debugElement.nativeElement.querySelector('set-button');
fixture.detectChanges();
fixture.whenStable().Then(() =>{
expect(component.clickFunction).toHaveBeenCalled();
})
});
I want to know what have i done wrong here.Thanks in advance