Skip to content

Commit 046461b

Browse files
nitinmalaveandrewseguin
authored andcommitted
test(material/chips): refactor variable type to const in chips component unit tests (#22898)
(cherry picked from commit e143b27)
1 parent 9f6a493 commit 046461b

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

src/material/chips/chip-input.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('MatChipInput', () => {
2020
let inputDebugElement: DebugElement;
2121
let inputNativeElement: HTMLElement;
2222
let chipInputDirective: MatChipInput;
23-
let dir = 'ltr';
23+
const dir = 'ltr';
2424

2525
beforeEach(waitForAsync(() => {
2626
TestBed.configureTestingModule({

src/material/chips/chip-list.spec.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ describe('MatChipList', () => {
188188
});
189189

190190
it('should watch for chip focus', () => {
191-
let array = chips.toArray();
192-
let lastIndex = array.length - 1;
193-
let lastItem = array[lastIndex];
191+
const array = chips.toArray();
192+
const lastIndex = array.length - 1;
193+
const lastItem = array[lastIndex];
194194

195195
lastItem.focus();
196196
fixture.detectChanges();
@@ -222,8 +222,8 @@ describe('MatChipList', () => {
222222
describe('on chip destroy', () => {
223223

224224
it('should focus the next item', () => {
225-
let array = chips.toArray();
226-
let midItem = array[2];
225+
const array = chips.toArray();
226+
const midItem = array[2];
227227

228228
// Focus the middle item
229229
midItem.focus();
@@ -237,9 +237,9 @@ describe('MatChipList', () => {
237237
});
238238

239239
it('should focus the previous item', () => {
240-
let array = chips.toArray();
241-
let lastIndex = array.length - 1;
242-
let lastItem = array[lastIndex];
240+
const array = chips.toArray();
241+
const lastIndex = array.length - 1;
242+
const lastItem = array[lastIndex];
243243

244244
// Focus the last item
245245
lastItem.focus();
@@ -253,8 +253,8 @@ describe('MatChipList', () => {
253253
});
254254

255255
it('should not focus if chip list is not focused', () => {
256-
let array = chips.toArray();
257-
let midItem = array[2];
256+
const array = chips.toArray();
257+
const midItem = array[2];
258258

259259
// Focus and blur the middle item
260260
midItem.focus();
@@ -317,12 +317,12 @@ describe('MatChipList', () => {
317317
});
318318

319319
it('should focus previous item when press LEFT ARROW', () => {
320-
let nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
321-
let lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement;
320+
const nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
321+
const lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement;
322322

323-
let array = chips.toArray();
324-
let lastIndex = array.length - 1;
325-
let lastItem = array[lastIndex];
323+
const array = chips.toArray();
324+
const lastIndex = array.length - 1;
325+
const lastItem = array[lastIndex];
326326

327327
// Focus the last item in the array
328328
lastItem.focus();
@@ -338,11 +338,11 @@ describe('MatChipList', () => {
338338
});
339339

340340
it('should focus next item when press RIGHT ARROW', () => {
341-
let nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
342-
let firstNativeChip = nativeChips[0] as HTMLElement;
341+
const nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
342+
const firstNativeChip = nativeChips[0] as HTMLElement;
343343

344-
let array = chips.toArray();
345-
let firstItem = array[0];
344+
const array = chips.toArray();
345+
const firstItem = array[0];
346346

347347
// Focus the last item in the array
348348
firstItem.focus();
@@ -406,12 +406,12 @@ describe('MatChipList', () => {
406406
});
407407

408408
it('should focus previous item when press RIGHT ARROW', () => {
409-
let nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
410-
let lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement;
409+
const nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
410+
const lastNativeChip = nativeChips[nativeChips.length - 1] as HTMLElement;
411411

412-
let array = chips.toArray();
413-
let lastIndex = array.length - 1;
414-
let lastItem = array[lastIndex];
412+
const array = chips.toArray();
413+
const lastIndex = array.length - 1;
414+
const lastItem = array[lastIndex];
415415

416416
// Focus the last item in the array
417417
lastItem.focus();
@@ -427,11 +427,11 @@ describe('MatChipList', () => {
427427
});
428428

429429
it('should focus next item when press LEFT ARROW', () => {
430-
let nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
431-
let firstNativeChip = nativeChips[0] as HTMLElement;
430+
const nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
431+
const firstNativeChip = nativeChips[0] as HTMLElement;
432432

433-
let array = chips.toArray();
434-
let firstItem = array[0];
433+
const array = chips.toArray();
434+
const firstItem = array[0];
435435

436436
// Focus the last item in the array
437437
firstItem.focus();
@@ -480,12 +480,12 @@ describe('MatChipList', () => {
480480
setupStandardList();
481481
manager = chipListInstance._keyManager;
482482

483-
let nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
484-
let firstNativeChip = nativeChips[0] as HTMLElement;
483+
const nativeChips = chipListNativeElement.querySelectorAll('mat-chip');
484+
const firstNativeChip = nativeChips[0] as HTMLElement;
485485

486-
let RIGHT_EVENT = createKeyboardEvent('keydown', RIGHT_ARROW);
487-
let array = chips.toArray();
488-
let firstItem = array[0];
486+
const RIGHT_EVENT = createKeyboardEvent('keydown', RIGHT_ARROW);
487+
const array = chips.toArray();
488+
const firstItem = array[0];
489489

490490
firstItem.focus();
491491
expect(manager.activeItemIndex).toBe(0);
@@ -537,7 +537,7 @@ describe('MatChipList', () => {
537537
describe('when the input has focus', () => {
538538

539539
it('should not focus the last chip when press DELETE', () => {
540-
let nativeInput = fixture.nativeElement.querySelector('input');
540+
const nativeInput = fixture.nativeElement.querySelector('input');
541541

542542
// Focus the input
543543
nativeInput.focus();
@@ -552,7 +552,7 @@ describe('MatChipList', () => {
552552
});
553553

554554
it('should focus the last chip when press BACKSPACE', () => {
555-
let nativeInput = fixture.nativeElement.querySelector('input');
555+
const nativeInput = fixture.nativeElement.querySelector('input');
556556

557557
// Focus the input
558558
nativeInput.focus();
@@ -1307,7 +1307,7 @@ describe('MatChipList', () => {
13071307
});
13081308

13091309
it('sets the aria-describedby to reference errors when in error state', () => {
1310-
let hintId =
1310+
const hintId =
13111311
fixture.debugElement.query(By.css('.mat-hint'))!.nativeElement.getAttribute('id');
13121312
let describedBy = chipListEl.getAttribute('aria-describedby');
13131313

@@ -1317,7 +1317,7 @@ describe('MatChipList', () => {
13171317
fixture.componentInstance.formControl.markAsTouched();
13181318
fixture.detectChanges();
13191319

1320-
let errorIds = fixture.debugElement.queryAll(By.css('.mat-error'))
1320+
const errorIds = fixture.debugElement.queryAll(By.css('.mat-error'))
13211321
.map(el => el.nativeElement.getAttribute('id')).join(' ');
13221322
describedBy = chipListEl.getAttribute('aria-describedby');
13231323

src/material/chips/chip-remove.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('Chip Remove', () => {
3131

3232
describe('basic behavior', () => {
3333
it('should apply a CSS class to the remove icon', () => {
34-
let buttonElement = chipNativeElement.querySelector('button')!;
34+
const buttonElement = chipNativeElement.querySelector('button')!;
3535

3636
expect(buttonElement.classList).toContain('mat-chip-remove');
3737
});
@@ -49,7 +49,7 @@ describe('Chip Remove', () => {
4949
});
5050

5151
it('should emit (removed) on click', () => {
52-
let buttonElement = chipNativeElement.querySelector('button')!;
52+
const buttonElement = chipNativeElement.querySelector('button')!;
5353

5454
testChip.removable = true;
5555
fixture.detectChanges();
@@ -63,7 +63,7 @@ describe('Chip Remove', () => {
6363
});
6464

6565
it('should not remove if parent chip is disabled', () => {
66-
let buttonElement = chipNativeElement.querySelector('button')!;
66+
const buttonElement = chipNativeElement.querySelector('button')!;
6767

6868
testChip.disabled = true;
6969
testChip.removable = true;

0 commit comments

Comments
 (0)