Skip to content

Commit

Permalink
fix(isOpen): fix isOpen attribute that when set would break this module
Browse files Browse the repository at this point in the history
Closes #14
  • Loading branch information
Matt Lewis committed Jun 23, 2016
1 parent 63dbfe9 commit fe5516d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 2 additions & 5 deletions src/confirm.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Confirm implements OnDestroy, OnChanges, OnInit {
/**
* Will emit when the popover is opened or closed
*/
@Output() isOpenChange: EventEmitter<any> = new EventEmitter();
@Output() isOpenChange: EventEmitter<any> = new EventEmitter(true);

/**
* An expression that is called when the confirm button is clicked.
Expand Down Expand Up @@ -164,10 +164,7 @@ export class Confirm implements OnDestroy, OnChanges, OnInit {
* @private
*/
ngOnInit(): void {
// needed because of https://github.com/angular/angular/issues/6005
setTimeout(() => {
this.isOpenChange.emit(false);
});
this.isOpenChange.emit(false);
}

/**
Expand Down
14 changes: 10 additions & 4 deletions test/angular2-bootstrap-confirm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ describe('bootstrap confirm', () => {
createPopoverContainer().then((fixture) => {
setTimeout(() => { // let isOpenChange be called with false
clickFixture();
expect(fixture.componentInstance.isOpen).toEqual(true);
setTimeout(() => {
expect(fixture.componentInstance.isOpen).toEqual(true);
});
});
});
}));
Expand All @@ -385,9 +387,13 @@ describe('bootstrap confirm', () => {
createPopoverContainer().then((fixture) => {
setTimeout(() => { // let isOpenChange be called with false
clickFixture();
expect(fixture.componentInstance.isOpen).toEqual(true);
clickFixture();
expect(fixture.componentInstance.isOpen).toEqual(false);
setTimeout(() => { // ugly set timeouts are required because isOpen is async
expect(fixture.componentInstance.isOpen).toEqual(true);
clickFixture();
setTimeout(() => {
expect(fixture.componentInstance.isOpen).toEqual(false);
});
});
});
});
}));
Expand Down

0 comments on commit fe5516d

Please sign in to comment.