-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new `tooltip` field of the ListItem class makes it possible to add extended information as a tooltip. Also refactor the component a bit so that the new field needs to be handled only at one place. Fixes #317
- Loading branch information
Showing
5 changed files
with
99 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/ng-multiselect-dropdown/test/multi-select-tooltip.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Component, ViewChild } from '@angular/core'; | ||
import { ComponentFixture, fakeAsync } from '@angular/core/testing'; | ||
import { MultiSelectComponent } from './../src/multiselect.component'; | ||
import { createTestingModule } from './helper'; | ||
|
||
@Component({ | ||
template: `` | ||
}) | ||
class Ng2MultiSelectDropdownMultipleSelectWithDisableItemComponent { | ||
@ViewChild(MultiSelectComponent, { static: false }) | ||
select: MultiSelectComponent; | ||
cities = [ | ||
{ item_id: 1, item_text: 'Mumbai' }, | ||
{ item_id: 2, item_text: 'Bangalore', tooltip_text: undefined }, | ||
{ item_id: 3, item_text: 'Pune', tooltip_text: '' }, | ||
{ item_id: 4, item_text: 'Navsari' }, | ||
{ item_id: 5, item_text: 'New Delhi', tooltip_text: 'The capital of India!' } | ||
]; | ||
selectedItem = [{ item_id: 1, item_text: 'Mumbai' }, { item_id: 4, item_text: 'Navsari' }]; | ||
dropdownSettings = { | ||
singleSelection: false, | ||
idField: 'item_id', | ||
textField: 'item_text', | ||
tooltipField: 'item_tooltip', | ||
selectAllText: 'Select All', | ||
unSelectAllText: 'UnSelect All', | ||
badgeShowLimit: 3, | ||
disabled: false, | ||
allowSearchFilter: true, | ||
closeDropDownOnSelection: true | ||
}; | ||
} | ||
describe('Multiple Selection:tooltip', () => { | ||
let fixture: ComponentFixture<Ng2MultiSelectDropdownMultipleSelectWithDisableItemComponent>; | ||
beforeEach(fakeAsync(() => { | ||
fixture = createTestingModule( | ||
Ng2MultiSelectDropdownMultipleSelectWithDisableItemComponent, | ||
`<div class='container'> | ||
<ng-multiselect-dropdown name="city" [data]="cities" | ||
[(ngModel)]="selectedItem" [settings]="dropdownSettings" | ||
(onSelect)="onItemSelect($event)" | ||
[disabled]="disabled"> | ||
</ng-multiselect-dropdown> | ||
</div>` | ||
); | ||
})); | ||
it('should show the tooltips', fakeAsync(() => { | ||
let selCheckBoxes: HTMLLIElement[]; | ||
const sel = fixture.nativeElement.querySelectorAll('.multiselect-item-checkbox'); | ||
selCheckBoxes = Array.from(sel); | ||
// Mumbai | ||
expect(selCheckBoxes[1].querySelector('div').textContent).toContain('Mumbai'); | ||
expect(selCheckBoxes[1].title).toBe(''); | ||
// Bangalore | ||
expect(selCheckBoxes[2].querySelector('div').textContent).toContain('Bangalore'); | ||
expect(selCheckBoxes[2].title).toBe(''); | ||
// Pune | ||
expect(selCheckBoxes[3].querySelector('div').textContent).toContain('Pune'); | ||
expect(selCheckBoxes[3].title).toBe(''); | ||
// Navsari | ||
expect(selCheckBoxes[4].querySelector('div').textContent).toContain('Navsari'); | ||
expect(selCheckBoxes[4].title).toBe('The capital of India!'); | ||
// New Delhi | ||
expect(selCheckBoxes[5].querySelector('div').textContent).toContain('New Delhi'); | ||
expect(selCheckBoxes[5].title).toBe(''); | ||
|
||
expect(fixture.componentInstance.selectedItem.length).toEqual(2); | ||
})); | ||
}); |