"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib/chips/chip-list.spec.ts" between
material2-7.3.4.tar.gz and material2-7.3.5.tar.gz

About: material2 offers Material Design components for Angular.

chip-list.spec.ts  (material2-7.3.4):chip-list.spec.ts  (material2-7.3.5)
skipping to change at line 97 skipping to change at line 97
}); });
it('should disable a chip that is added after the list became disabled', f akeAsync(() => { it('should disable a chip that is added after the list became disabled', f akeAsync(() => {
expect(chips.toArray().every(chip => chip.disabled)).toBe(false); expect(chips.toArray().every(chip => chip.disabled)).toBe(false);
chipListInstance.disabled = true; chipListInstance.disabled = true;
fixture.detectChanges(); fixture.detectChanges();
expect(chips.toArray().every(chip => chip.disabled)).toBe(true); expect(chips.toArray().every(chip => chip.disabled)).toBe(true);
fixture.componentInstance.items.push(5, 6); fixture.componentInstance.chips.push(5, 6);
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
fixture.detectChanges(); fixture.detectChanges();
expect(chips.toArray().every(chip => chip.disabled)).toBe(true); expect(chips.toArray().every(chip => chip.disabled)).toBe(true);
})); }));
}); });
describe('with selected chips', () => { describe('with selected chips', () => {
skipping to change at line 199 skipping to change at line 199
describe('on chip destroy', () => { describe('on chip destroy', () => {
it('should focus the next item', () => { it('should focus the next item', () => {
let array = chips.toArray(); let array = chips.toArray();
let midItem = array[2]; let midItem = array[2];
// Focus the middle item // Focus the middle item
midItem.focus(); midItem.focus();
// Remove the middle item // Destroy the middle item
testComponent.items.splice(2, 1); testComponent.chips.splice(2, 1);
fixture.detectChanges(); fixture.detectChanges();
// It focuses the 4th item (now at index 2) // It focuses the 4th item (now at index 2)
expect(manager.activeItemIndex).toEqual(2); expect(manager.activeItemIndex).toEqual(2);
}); });
it('should focus the previous item', () => { it('should focus the previous item', () => {
let array = chips.toArray(); let array = chips.toArray();
let lastIndex = array.length - 1; let lastIndex = array.length - 1;
let lastItem = array[lastIndex]; let lastItem = array[lastIndex];
// Focus the last item // Focus the last item
lastItem.focus(); lastItem.focus();
// Remove the last item // Destroy the last item
testComponent.items.splice(lastIndex, 1); testComponent.chips.pop();
fixture.detectChanges(); fixture.detectChanges();
// It focuses the next-to-last item // It focuses the next-to-last item
expect(manager.activeItemIndex).toEqual(lastIndex - 1); expect(manager.activeItemIndex).toEqual(lastIndex - 1);
}); });
it('should not focus if chip list is not focused', () => { it('should not focus if chip list is not focused', () => {
let array = chips.toArray(); let array = chips.toArray();
let midItem = array[2]; let midItem = array[2];
// Focus and blur the middle item // Focus and blur the middle item
midItem.focus(); midItem.focus();
midItem._blur(); midItem._blur();
zone.simulateZoneExit(); zone.simulateZoneExit();
// Remove the middle item // Destroy the middle item
testComponent.items.splice(2, 1); testComponent.chips.splice(2, 1);
fixture.detectChanges(); fixture.detectChanges();
// Should not have focus // Should not have focus
expect(chipListInstance._keyManager.activeItemIndex).toEqual(-1); expect(chipListInstance._keyManager.activeItemIndex).toEqual(-1);
}); });
it('should move focus to the last chip when the focused chip was deleted inside a' + it('should move focus to the last chip when the focused chip was deleted inside a' +
'component with animations', fakeAsync(() => { 'component with animations', fakeAsync(() => {
fixture.destroy(); fixture.destroy();
TestBed.resetTestingModule(); TestBed.resetTestingModule();
skipping to change at line 1317 skipping to change at line 1317
chipListInstance = chipListDebugElement.componentInstance; chipListInstance = chipListDebugElement.componentInstance;
testComponent = fixture.debugElement.componentInstance; testComponent = fixture.debugElement.componentInstance;
chips = chipListInstance.chips; chips = chipListInstance.chips;
} }
}); });
@Component({ @Component({
template: ` template: `
<mat-chip-list [tabIndex]="tabIndex" [selectable]="selectable"> <mat-chip-list [tabIndex]="tabIndex" [selectable]="selectable">
<mat-chip *ngFor="let i of items" <mat-chip *ngFor="let i of chips" (select)="chipSelect(i)" (deselect)="chi
(select)="chipSelect(i)" pDeselect(i)">
(deselect)="chipDeselect(i)">
{{name}} {{i + 1}} {{name}} {{i + 1}}
</mat-chip> </mat-chip>
</mat-chip-list>` </mat-chip-list>`
}) })
class StandardChipList { class StandardChipList {
items = [0, 1, 2, 3, 4];
name: string = 'Test'; name: string = 'Test';
selectable: boolean = true; selectable: boolean = true;
chipSelect: (index?: number) => void = () => {}; chipSelect: (index?: number) => void = () => {};
chipDeselect: (index?: number) => void = () => {}; chipDeselect: (index?: number) => void = () => {};
tabIndex: number = 0; tabIndex: number = 0;
chips = [0, 1, 2, 3, 4];
} }
@Component({ @Component({
template: ` template: `
<mat-form-field> <mat-form-field>
<mat-label>Add a chip</mat-label> <mat-label>Add a chip</mat-label>
<mat-chip-list #chipList> <mat-chip-list #chipList>
<mat-chip *ngFor="let chip of chips" (removed)="remove(chip)">{{chip}}</ mat-chip> <mat-chip *ngFor="let chip of chips" (removed)="remove(chip)">{{chip}}</ mat-chip>
</mat-chip-list> </mat-chip-list>
<input name="test" [matChipInputFor]="chipList"/> <input name="test" [matChipInputFor]="chipList"/>
skipping to change at line 1583 skipping to change at line 1581
if (index > -1) { if (index > -1) {
this.numbers.splice(index, 1); this.numbers.splice(index, 1);
} }
} }
} }
@Component({ @Component({
template: ` template: `
<mat-form-field> <mat-form-field>
<mat-chip-list> <mat-chip-list>
<mat-chip *ngFor="let i of chips" [value]="i" (removed)="removeChip($eve nt)"> <mat-chip [value]="i" (removed)="removeChip($event)" *ngFor="let i of ch ips">
Chip {{i + 1}} Chip {{i + 1}}
<span matChipRemove>Remove</span> <span matChipRemove>Remove</span>
</mat-chip> </mat-chip>
</mat-chip-list> </mat-chip-list>
</mat-form-field> </mat-form-field>
` `
}) })
class ChipListWithRemove { class ChipListWithRemove {
chips = [0, 1, 2, 3, 4]; chips = [0, 1, 2, 3, 4];
 End of changes. 8 change blocks. 
12 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)