Skip to content

fix(select): remove selection if option is removed #2560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,28 @@ describe('MdSelect', () => {
expect(optionInstances[2].selected).toBe(false);
});

it('should remove selection if option has been removed', async(() => {
let select = fixture.componentInstance.select;

trigger.click();
fixture.detectChanges();

let firstOption = overlayContainerElement.querySelectorAll('md-option')[0] as HTMLElement;

firstOption.click();
fixture.detectChanges();

expect(select.selected).toBe(select.options.first, 'Expected first option to be selected.');

fixture.componentInstance.foods = [];
fixture.detectChanges();

fixture.whenStable().then(() => {
expect(select.selected)
.toBe(null, 'Expected selection to be removed when option no longer exists.');
});
}));

it('should display the selected option in the trigger', () => {
trigger.click();
fixture.detectChanges();
Expand Down