Skip to content

test(chip-list): rework tests to work under Ivy #15427

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 1 commit into from
Mar 11, 2019
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
28 changes: 11 additions & 17 deletions src/lib/chips/chip-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('MatChipList', () => {
midItem.focus();

// Destroy the middle item
testComponent.remove = 2;
testComponent.chips.splice(2, 1);
fixture.detectChanges();

// It focuses the 4th item (now at index 2)
Expand All @@ -197,7 +197,7 @@ describe('MatChipList', () => {
lastItem.focus();

// Destroy the last item
testComponent.remove = lastIndex;
testComponent.chips.pop();
fixture.detectChanges();

// It focuses the next-to-last item
Expand All @@ -214,7 +214,7 @@ describe('MatChipList', () => {
zone.simulateZoneExit();

// Destroy the middle item
testComponent.remove = 2;
testComponent.chips.splice(2, 1);
fixture.detectChanges();

// Should not have focus
Expand Down Expand Up @@ -1305,22 +1305,18 @@ describe('MatChipList', () => {
@Component({
template: `
<mat-chip-list [tabIndex]="tabIndex" [selectable]="selectable">
<div *ngFor="let i of [0,1,2,3,4]">
<div *ngIf="remove != i">
<mat-chip (select)="chipSelect(i)" (deselect)="chipDeselect(i)">
{{name}} {{i + 1}}
</mat-chip>
</div>
</div>
<mat-chip *ngFor="let i of chips" (select)="chipSelect(i)" (deselect)="chipDeselect(i)">
{{name}} {{i + 1}}
</mat-chip>
</mat-chip-list>`
})
class StandardChipList {
name: string = 'Test';
selectable: boolean = true;
remove: number;
chipSelect: (index?: number) => void = () => {};
chipDeselect: (index?: number) => void = () => {};
tabIndex: number = 0;
chips = [0, 1, 2, 3, 4];
}

@Component({
Expand Down Expand Up @@ -1576,12 +1572,10 @@ class StandardChipListWithAnimations {
template: `
<mat-form-field>
<mat-chip-list>
<div *ngFor="let i of chips">
<mat-chip [value]="i" (removed)="removeChip($event)">
Chip {{i + 1}}
<span matChipRemove>Remove</span>
</mat-chip>
</div>
<mat-chip [value]="i" (removed)="removeChip($event)" *ngFor="let i of chips">
Chip {{i + 1}}
<span matChipRemove>Remove</span>
</mat-chip>
</mat-chip-list>
</mat-form-field>
`
Expand Down