I have this child component that emit true or false when the style change to a parent component:
export class PruebaComponent implements OnInit, OnChanges {
@Output() statusEvent = new EventEmitter<boolean>();
getSytle(): string {
return this.valueStyle;
}
private calcStyle(): void {
this.calcPopUpStyle();
if (this.isEngReady) {
this.valueStyle = 'icon-green';
this.statusEvent .emit(true);
} else {
this.valueStyle = 'icon-red';
this.statusEvent.emit(false);
}
this.ref.detectChanges();
}
}
I trying to write the test to check that the statusEvent emitted is true when the isEngReady is also true, that I tried this:
describe('PruebaComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ChatComponent]})
.compileComponents();
}));
it('should emit chat availability to true if the engagement is available', () => {
spyOn(component.chatAvailableEvent, 'emit')
component.isEngReady = true;
component.getSytle();
//expect(component.statusEvent.emit).toHaveBeenCalled();
expect(component.statusEvent.emit).toHaveBeenCalledWith(true);
});
});
But I receive this error message: Expected spy emit to have been called with: [ true ] but it was never called.
Aucun commentaire:
Enregistrer un commentaire