Skip to content

Commit

Permalink
issue112: + add opened event emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii boiko committed Feb 16, 2019
1 parent 4ef4575 commit 5bc9cc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ describe('NgxMaterialTimepickerComponent', () => {
expect(component.selectedPeriod).toBe(TimePeriod.AM);
});

it(`should set isOpened 'true' and change animationState to 'enter' on open call`, () => {
it(`should set isOpened 'true', change animationState to 'enter' and emit event on open call`, async(() => {
let counter = 0;

component.opened.subscribe(() => expect(++counter).toBe(1));
component.open();
expect(component.isOpened).toBeTruthy();
expect(component.animationState).toBe(AnimationState.ENTER);
});
}));

it('should change animationState to \'leave\' on close call', () => {
component.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class NgxMaterialTimepickerComponent implements OnInit, OnDestroy {
}

@Output() timeSet = new EventEmitter<string>();
@Output() opened = new EventEmitter<null>();
@Output() closed = new EventEmitter<null>();
@Output() hourSelected = new EventEmitter<number>();

Expand Down Expand Up @@ -163,6 +164,7 @@ export class NgxMaterialTimepickerComponent implements OnInit, OnDestroy {
open(): void {
this.isOpened = true;
this.animationState = AnimationState.ENTER;
this.opened.next();
}

close(): void {
Expand Down

0 comments on commit 5bc9cc0

Please sign in to comment.