diff --git a/src/lib/select/select.spec.ts b/src/lib/select/select.spec.ts index b7a26cb0fb7..b6b5526d119 100644 --- a/src/lib/select/select.spec.ts +++ b/src/lib/select/select.spec.ts @@ -2453,6 +2453,22 @@ describe('MatSelect', () => { expect(component.select.errorState).toBe(true); expect(errorStateMatcher.isErrorState).toHaveBeenCalled(); })); + + it('should notify that the state changed when the options have changed', fakeAsync(() => { + testComponent.formControl.setValue('pizza-1'); + fixture.detectChanges(); + + const spy = jasmine.createSpy('stateChanges spy'); + const subscription = testComponent.select.stateChanges.subscribe(spy); + + testComponent.options = []; + fixture.detectChanges(); + tick(); + + expect(spy).toHaveBeenCalled(); + subscription.unsubscribe(); + })); + }); describe('with custom error behavior', () => { @@ -4640,8 +4656,9 @@ class InvalidSelectInForm {