Skip to content

Commit

Permalink
fix(select): allow initial falsy values (#1936)
Browse files Browse the repository at this point in the history
  • Loading branch information
yggg authored Aug 29, 2019
1 parent c9b9d32 commit 02080fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/framework/theme/components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ export class NbSelectComponent<T> implements AfterViewInit, AfterContentInit, On
}

ngAfterContentInit() {
if (this.queue) {
if (this.queue != null) {
// Call 'writeValue' when current change detection run is finished.
// When writing is finished, change detection starts again, since
// microtasks queue is empty.
Expand Down
13 changes: 13 additions & 0 deletions src/framework/theme/components/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,19 @@ describe('NbSelectComponent - falsy values', () => {
expect(testComponent.truthyOptionElement.nativeElement.querySelector('nb-checkbox')).not.toEqual(null);
});
});

it('should select initial falsy value', fakeAsync(() => {
fixture = TestBed.createComponent(NbSelectWithFalsyOptionValuesComponent);
testComponent = fixture.componentInstance;
select = fixture.debugElement.query(By.directive(NbSelectComponent)).componentInstance;

select.selected = '';
fixture.detectChanges();
flush();

expect(select.selectionModel[0]).toEqual(testComponent.emptyStringOption);
expect(testComponent.emptyStringOption.selected).toEqual(true);
}));
});

describe('NbSelectComponent - Triggers', () => {
Expand Down

0 comments on commit 02080fb

Please sign in to comment.