Skip to content

Commit

Permalink
fix(select): complete state change event (#8777)
Browse files Browse the repository at this point in the history
* fix(select): complete state change event

* chore: add event test
  • Loading branch information
amcdnl authored and andrewseguin committed Dec 13, 2017
1 parent 8a3b19e commit 4f78613
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,25 @@ describe('MatSelect', () => {
}));
});

describe('change events', () => {
beforeEach(async(() => configureMatSelectTestingModule([SelectWithPlainTabindex])));

it('should complete the stateChanges stream on destroy', () => {
const fixture = TestBed.createComponent(SelectWithPlainTabindex);
fixture.detectChanges();

const debugElement = fixture.debugElement.query(By.directive(MatSelect));
const select = debugElement.componentInstance;

const spy = jasmine.createSpy('stateChanges complete');
const subscription = select.stateChanges.subscribe(undefined, undefined, spy);

fixture.destroy();
expect(spy).toHaveBeenCalled();
subscription.unsubscribe();
});
});

describe('when initially hidden', () => {
beforeEach(async(() => configureMatSelectTestingModule([BasicSelectInitiallyHidden])));

Expand Down
1 change: 1 addition & 0 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
ngOnDestroy() {
this._destroy.next();
this._destroy.complete();
this.stateChanges.complete();
}

/** Toggles the overlay panel open or closed. */
Expand Down

0 comments on commit 4f78613

Please sign in to comment.