Skip to content

Commit

Permalink
test(material/chips): remove unnecessary animations test
Browse files Browse the repository at this point in the history
Removes a test checking the chips with the animations module. I believe this is something we inherited from the legacy chips, but it's not really relevant anymore.
  • Loading branch information
crisbeto committed Jan 31, 2025
1 parent 3b86ff7 commit 9e1ee2f
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions src/material/chips/chip-grid.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {animate, style, transition, trigger} from '@angular/animations';
import {Direction, Directionality} from '@angular/cdk/bidi';
import {
BACKSPACE,
Expand Down Expand Up @@ -122,9 +121,7 @@ describe('MatChipGrid', () => {
});

describe('focus behaviors', () => {
let fixture:
| ComponentFixture<StandardChipGrid>
| ComponentFixture<StandardChipGridWithAnimations>;
let fixture: ComponentFixture<StandardChipGrid>;

beforeEach(() => {
fixture = createComponent(StandardChipGrid);
Expand Down Expand Up @@ -232,23 +229,6 @@ describe('MatChipGrid', () => {

expect(chipGridInstance.focus).toHaveBeenCalled();
});

it('should move focus to the last chip when the focused chip was deleted inside a component with animations', fakeAsync(() => {
fixture.destroy();
TestBed.resetTestingModule();

fixture = createComponent(StandardChipGridWithAnimations, BrowserAnimationsModule);

patchElementFocus(chips.last.primaryAction!._elementRef.nativeElement);
chips.last.focus();
fixture.detectChanges();

dispatchKeyboardEvent(chips.last._elementRef.nativeElement, 'keydown', BACKSPACE);
fixture.detectChanges();
tick(500);

expect(document.activeElement).toBe(primaryActions[primaryActions.length - 2]);
}));
});

it('should have a focus indicator', () => {
Expand Down Expand Up @@ -1218,35 +1198,6 @@ class ChipGridWithFormErrorMessages {
}
}

@Component({
template: `
<mat-chip-grid #chipGrid>
@for (i of numbers; track i) {
<mat-chip-row (removed)="remove(i)">{{i}}</mat-chip-row>
}
<input name="test" [matChipInputFor]="chipGrid"/>
</mat-chip-grid>`,
animations: [
// For the case we're testing this animation doesn't
// have to be used anywhere, it just has to be defined.
trigger('dummyAnimation', [
transition(':leave', [style({opacity: 0}), animate('500ms', style({opacity: 1}))]),
]),
],
standalone: false,
})
class StandardChipGridWithAnimations {
numbers = [0, 1, 2, 3, 4];

remove(item: number): void {
const index = this.numbers.indexOf(item);

if (index > -1) {
this.numbers.splice(index, 1);
}
}
}

@Component({
template: `
<mat-form-field>
Expand Down

0 comments on commit 9e1ee2f

Please sign in to comment.