Skip to content

Commit

Permalink
pull-192: cover by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
optimistex committed Nov 30, 2020
1 parent ed053d5 commit e27545a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/app/lib/ngx-select/ngx-select.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,28 @@ describe('NgxSelectComponent', () => {
expect(doRemove).toHaveBeenCalledWith(0);
});
});

it('should not remove items on `allowClear=false` for non multiselect', () => {
// issue: https://github.com/optimistex/ngx-select-ex/issues/191

doRemove = spyOn(fixture.componentInstance.select2, 'doRemove');
fixture.componentInstance.select2.items = items1;
fixture.componentInstance.select2.allowClear = false;
fixture.detectChanges();
formControl(2).click();
fixture.detectChanges();
selectItemList(2)[0].click();
fixture.detectChanges();
expect(selectedItem(2).innerHTML).toContain('item zero');
expect(fixture.componentInstance.select2.formControl.value).toEqual(0);

el(2).dispatchEvent(createKeyboardEvent('keydown', 'Delete'));
fixture.detectChanges();
expect(selectedItem(2).innerHTML).toContain('item zero');
expect(fixture.componentInstance.select2.formControl.value).toEqual(0);

expect(doRemove).not.toHaveBeenCalled();
});
});

describe('after click', () => {
Expand Down

0 comments on commit e27545a

Please sign in to comment.