NetanelBasal
5/24/2017 - 1:31 PM

app-alert4.component.ts

it('should emit the close event when clicking on the x button', function () {
  const template = '<app-alert [show]="true">Alert</app-alert>';
  fixture = createHostComponent(template);
  const alertComponent = fixture.debugElement.query(By.directive(AlertComponent)) as DebugElement;
  const closeEle = alertComponent.query(By.css('.close')) as DebugElement;
  let $event;
  alertComponent.componentInstance.close.subscribe(val => $event = val);
  closeEle.triggerEventHandler('click', null);
  expect($event).toEqual(true);
});