Skip to content

Commit

Permalink
feat(unit-test): add test for action tomastrajan#177
Browse files Browse the repository at this point in the history
  • Loading branch information
shootermv committed May 14, 2018
1 parent 30af196 commit fbd30ab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app/shared/big-input/big-input-action.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { By } from '@angular/platform-browser';
import { SharedModule } from '@app/shared';

import { Component } from '@angular/core';
Expand All @@ -11,6 +11,7 @@ import { Component } from '@angular/core';
color="warn"
[icon]="icon"
[label]="label"
(action)="actionHandler()"
[disabled]="disabled"
>
</anms-big-input-action>
Expand All @@ -20,6 +21,7 @@ class HostComponent {
disabled;
icon;
label;
actionHandler;
}
describe('BigInputActionComponent', () => {
let component: HostComponent;
Expand Down Expand Up @@ -80,4 +82,13 @@ describe('BigInputActionComponent', () => {
expect(label).toBeTruthy();
expect(label.textContent).toBe('delete');
});

it('should trigger action bound when button clicked', () => {
const button = fixture.debugElement.query(By.css('button'));
component.actionHandler = () => {};
fixture.detectChanges();
spyOn(component, 'actionHandler').and.callThrough();
button.triggerEventHandler('click', <Event>{});
expect(component.actionHandler).toHaveBeenCalled();
});
});

0 comments on commit fbd30ab

Please sign in to comment.