Skip to content

Commit ee312c6

Browse files
committed
test(material/button-toggle): refactor variable type to const in button-toggle component unit tests
style(material/button-toggle): fix tslint max-line-length exceeds issue in ci build
1 parent 23dfbbb commit ee312c6

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/material/button-toggle/button-toggle.spec.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('MatButtonToggle with forms', () => {
6363
});
6464

6565
it('should register the on change callback', () => {
66-
let spy = jasmine.createSpy('onChange callback');
66+
const spy = jasmine.createSpy('onChange callback');
6767

6868
testComponent.control.registerOnChange(spy);
6969
testComponent.control.setValue('blue');
@@ -413,7 +413,7 @@ describe('MatButtonToggle without forms', () => {
413413
it('should emit a change event from button toggles', fakeAsync(() => {
414414
expect(buttonToggleInstances[0].checked).toBe(false);
415415

416-
let changeSpy = jasmine.createSpy('button-toggle change listener');
416+
const changeSpy = jasmine.createSpy('button-toggle change listener');
417417
buttonToggleInstances[0].change.subscribe(changeSpy);
418418

419419
buttonToggleLabelElements[0].click();
@@ -432,7 +432,7 @@ describe('MatButtonToggle without forms', () => {
432432
it('should emit a change event from the button toggle group', fakeAsync(() => {
433433
expect(groupInstance.value).toBeFalsy();
434434

435-
let changeSpy = jasmine.createSpy('button-toggle-group change listener');
435+
const changeSpy = jasmine.createSpy('button-toggle-group change listener');
436436
groupInstance.change.subscribe(changeSpy);
437437

438438
buttonToggleLabelElements[0].click();
@@ -497,10 +497,10 @@ describe('MatButtonToggle without forms', () => {
497497
describe('with initial value and change event', () => {
498498

499499
it('should not fire an initial change event', () => {
500-
let fixture = TestBed.createComponent(ButtonToggleGroupWithInitialValue);
501-
let testComponent = fixture.debugElement.componentInstance;
502-
let groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup))!;
503-
let groupInstance: MatButtonToggleGroup = groupDebugElement.injector
500+
const fixture = TestBed.createComponent(ButtonToggleGroupWithInitialValue);
501+
const testComponent = fixture.debugElement.componentInstance;
502+
const groupDebugElement = fixture.debugElement.query(By.directive(MatButtonToggleGroup))!;
503+
const groupInstance: MatButtonToggleGroup = groupDebugElement.injector
504504
.get<MatButtonToggleGroup>(MatButtonToggleGroup);
505505

506506
fixture.detectChanges();
@@ -559,7 +559,8 @@ describe('MatButtonToggle without forms', () => {
559559
it('should check a button toggle when clicked', () => {
560560
expect(buttonToggleInstances.every(buttonToggle => !buttonToggle.checked)).toBe(true);
561561

562-
let nativeCheckboxLabel = buttonToggleDebugElements[0].query(By.css('button'))!.nativeElement;
562+
const nativeCheckboxLabel =
563+
buttonToggleDebugElements[0].query(By.css('button'))!.nativeElement;
563564

564565
nativeCheckboxLabel.click();
565566

@@ -583,7 +584,7 @@ describe('MatButtonToggle without forms', () => {
583584
});
584585

585586
it('should check a button toggle upon interaction with underlying native checkbox', () => {
586-
let nativeCheckboxButton =
587+
const nativeCheckboxButton =
587588
buttonToggleDebugElements[0].query(By.css('button'))!.nativeElement;
588589

589590
nativeCheckboxButton.click();
@@ -621,7 +622,7 @@ describe('MatButtonToggle without forms', () => {
621622
it('should emit a change event for state changes', fakeAsync(() => {
622623
expect(buttonToggleInstances[0].checked).toBe(false);
623624

624-
let changeSpy = jasmine.createSpy('button-toggle change listener');
625+
const changeSpy = jasmine.createSpy('button-toggle change listener');
625626
buttonToggleInstances[0].change.subscribe(changeSpy);
626627

627628
buttonToggleLabelElements[0].click();
@@ -688,7 +689,7 @@ describe('MatButtonToggle without forms', () => {
688689

689690
expect(buttonToggleInstance.checked).toBe(false);
690691

691-
let changeSpy = jasmine.createSpy('button-toggle change listener');
692+
const changeSpy = jasmine.createSpy('button-toggle change listener');
692693
buttonToggleInstance.change.subscribe(changeSpy);
693694

694695
buttonToggleLabelElement.click();
@@ -706,7 +707,7 @@ describe('MatButtonToggle without forms', () => {
706707
}));
707708

708709
it('should focus on underlying input element when focus() is called', () => {
709-
let nativeButton = buttonToggleDebugElement.query(By.css('button'))!.nativeElement;
710+
const nativeButton = buttonToggleDebugElement.query(By.css('button'))!.nativeElement;
710711
expect(document.activeElement).not.toBe(nativeButton);
711712

712713
buttonToggleInstance.focus();
@@ -734,20 +735,20 @@ describe('MatButtonToggle without forms', () => {
734735

735736
describe('aria-label handling ', () => {
736737
it('should not set the aria-label attribute if none is provided', () => {
737-
let fixture = TestBed.createComponent(StandaloneButtonToggle);
738-
let checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
739-
let checkboxNativeElement = checkboxDebugElement.nativeElement;
740-
let buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;
738+
const fixture = TestBed.createComponent(StandaloneButtonToggle);
739+
const checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
740+
const checkboxNativeElement = checkboxDebugElement.nativeElement;
741+
const buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;
741742

742743
fixture.detectChanges();
743744
expect(buttonElement.hasAttribute('aria-label')).toBe(false);
744745
});
745746

746747
it('should use the provided aria-label', () => {
747-
let fixture = TestBed.createComponent(ButtonToggleWithAriaLabel);
748-
let checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
749-
let checkboxNativeElement = checkboxDebugElement.nativeElement;
750-
let buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;
748+
const fixture = TestBed.createComponent(ButtonToggleWithAriaLabel);
749+
const checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
750+
const checkboxNativeElement = checkboxDebugElement.nativeElement;
751+
const buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;
751752

752753
fixture.detectChanges();
753754
expect(buttonElement.getAttribute('aria-label')).toBe('Super effective');
@@ -770,7 +771,7 @@ describe('MatButtonToggle without forms', () => {
770771
let buttonElement: HTMLButtonElement;
771772

772773
it('should use the provided aria-labelledby', () => {
773-
let fixture = TestBed.createComponent(ButtonToggleWithAriaLabelledby);
774+
const fixture = TestBed.createComponent(ButtonToggleWithAriaLabelledby);
774775
checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
775776
checkboxNativeElement = checkboxDebugElement.nativeElement;
776777
buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;
@@ -780,7 +781,7 @@ describe('MatButtonToggle without forms', () => {
780781
});
781782

782783
it('should not assign aria-labelledby if none is provided', () => {
783-
let fixture = TestBed.createComponent(StandaloneButtonToggle);
784+
const fixture = TestBed.createComponent(StandaloneButtonToggle);
784785
checkboxDebugElement = fixture.debugElement.query(By.directive(MatButtonToggle))!;
785786
checkboxNativeElement = checkboxDebugElement.nativeElement;
786787
buttonElement = checkboxNativeElement.querySelector('button') as HTMLButtonElement;

0 commit comments

Comments
 (0)