fix(select): complete state change event (#8777)

* fix(select): complete state change event

* chore: add event test
This commit is contained in:
Austin
2017-12-13 15:53:41 -06:00
committed by Andrew Seguin
parent 8a3b19ea92
commit 4f7861333a
2 changed files with 20 additions and 0 deletions
+19
View File
@@ -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])));
+1
View File
@@ -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. */