Skip to content

Commit 7e3c840

Browse files
committed
refactor(time-picker): fix lint errors #6482
1 parent 304daed commit 7e3c840

File tree

4 files changed

+113
-112
lines changed

4 files changed

+113
-112
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import { IgxLabelDirective } from './../directives/label/label.directive';
2-
import { Component, ViewChild, NgModule, ElementRef, EventEmitter, DebugElement } from '@angular/core';
1+
import { Component, ViewChild, DebugElement } from '@angular/core';
32
import { TestBed, fakeAsync, tick, ComponentFixture, waitForAsync } from '@angular/core/testing';
4-
import { FormsModule, FormGroup, FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
3+
import { FormsModule } from '@angular/forms';
54
import { By } from '@angular/platform-browser';
65
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
7-
import { IgxInputDirective, IgxInputState } from '../directives/input/input.directive';
86
import { IgxTimePickerComponent, IgxTimePickerModule, IgxTimePickerValidationFailedEventArgs } from './time-picker.component';
9-
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
10-
import { IgxInputGroupModule, IgxInputGroupComponent } from '../input-group/public_api';
7+
import { UIInteractions } from '../test-utils/ui-interactions.spec';
8+
import { IgxInputGroupModule } from '../input-group/public_api';
119
import { configureTestSuite } from '../test-utils/configure-suite';
1210
import { PickerInteractionMode } from '../date-common/types';
1311
import { IgxIconModule } from '../icon/public_api';
14-
import { IgxToggleDirective, IgxToggleModule } from '../directives/toggle/toggle.directive';
15-
import { IBaseCancelableBrowserEventArgs, IBaseEventArgs, KEYS } from '../core/utils';
16-
import { DatePart, IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api';
17-
import { IgxItemListDirective } from './time-picker.directives';
12+
import { IgxToggleDirective } from '../directives/toggle/toggle.directive';
13+
import { KEYS } from '../core/utils';
14+
import { DatePart } from '../directives/date-time-editor/public_api';
1815
import { DateTimeUtil } from '../date-common/util/date-time.util';
19-
import { time } from 'console';
2016

2117
const CSS_CLASS_TIMEPICKER = 'igx-time-picker';
2218
const CSS_CLASS_INPUTGROUP = 'igx-input-group';
@@ -25,11 +21,10 @@ const CSS_CLASS_INPUT = '.igx-input-group__input';
2521
const CSS_CLASS_DROPDOWN = '.igx-time-picker--dropdown';
2622
const CSS_CLASS_HOURLIST = '.igx-time-picker__hourList';
2723
const CSS_CLASS_MINUTELIST = '.igx-time-picker__minuteList';
28-
const CSS_CLASS_SECONDSLIST = '.igx-time-picker__secondsList';
24+
// const CSS_CLASS_SECONDSLIST = '.igx-time-picker__secondsList';
2925
const CSS_CLASS_AMPMLIST = '.igx-time-picker__ampmList';
3026
const CSS_CLASS_SELECTED_ITEM = '.igx-time-picker__item--selected';
3127
const CSS_CLASS_HEADER_HOUR = '.igx-time-picker__header-hour';
32-
const CSS_CLASS_HEADER_AMPM = '.igx-time-picker__header-ampm';
3328
const CSS_CLASS_OVERLAY = 'igx-overlay';
3429
const CSS_CLASS_OVERLAY_WRAPPER = 'igx-overlay__wrapper';
3530

@@ -55,7 +50,7 @@ describe('IgxTimePicker', () => {
5550
timePicker.open();
5651
expect(mockToggleDirective.open).toHaveBeenCalledTimes(1);
5752

58-
(Object.getOwnPropertyDescriptor(mockToggleDirective, "collapsed")?.get as jasmine.Spy<() => boolean>).and.returnValue(false);
53+
(Object.getOwnPropertyDescriptor(mockToggleDirective, 'collapsed')?.get as jasmine.Spy<() => boolean>).and.returnValue(false);
5954
timePicker.close();
6055
expect(mockToggleDirective.close).toHaveBeenCalledTimes(1);
6156
});
@@ -70,7 +65,7 @@ describe('IgxTimePicker', () => {
7065
timePicker.toggle();
7166
expect(mockToggleDirective.open).toHaveBeenCalledTimes(1);
7267

73-
(Object.getOwnPropertyDescriptor(mockToggleDirective, "collapsed")?.get as jasmine.Spy<() => boolean>).and.returnValue(false);
68+
(Object.getOwnPropertyDescriptor(mockToggleDirective, 'collapsed')?.get as jasmine.Spy<() => boolean>).and.returnValue(false);
7469
timePicker.toggle();
7570
expect(mockToggleDirective.close).toHaveBeenCalledTimes(1);
7671
});
@@ -239,7 +234,7 @@ describe('IgxTimePicker', () => {
239234
expect(timePicker.value).toEqual(pickerValue);
240235
}));
241236

242-
it('should open the dropdown with `ArrowDown` + `Alt` key press and close it and keep the current selection on outside click', fakeAsync(() => {
237+
it('should open the dropdown with `ArrowDown` + `Alt` key press and close it on outside click', fakeAsync(() => {
243238
input.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', altKey: true }));
244239
tick();
245240
fixture.detectChanges();
@@ -465,7 +460,7 @@ describe('IgxTimePicker', () => {
465460
fixture = TestBed.createComponent(IgxTimePickerTestComponent);
466461
fixture.detectChanges();
467462
timePicker = fixture.componentInstance.timePicker;
468-
timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)).nativeElement;
463+
// timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)).nativeElement;
469464
inputGroup = fixture.debugElement.query(By.css(`.${CSS_CLASS_INPUTGROUP}`));
470465
hourColumn = fixture.debugElement.query(By.css(CSS_CLASS_HOURLIST));
471466
minutesColumn = fixture.debugElement.query(By.css(CSS_CLASS_MINUTELIST));
@@ -562,41 +557,43 @@ describe('IgxTimePicker', () => {
562557
}));
563558

564559
it('should apply all aria attributes correctly', fakeAsync(() => {
565-
const input = fixture.nativeElement.querySelector(CSS_CLASS_INPUT);
566-
expect(input.getAttribute('role')).toEqual('combobox');
567-
expect(input.getAttribute('aria-haspopup')).toEqual('dialog');
568-
expect(input.getAttribute('aria-labelledby')).toEqual(timePicker.label.id);
569-
expect(input.getAttribute('aria-expanded')).toEqual('false');
560+
const inputEl = fixture.nativeElement.querySelector(CSS_CLASS_INPUT);
561+
expect(inputEl.getAttribute('role')).toEqual('combobox');
562+
expect(inputEl.getAttribute('aria-haspopup')).toEqual('dialog');
563+
expect(inputEl.getAttribute('aria-labelledby')).toEqual(timePicker.label.id);
564+
expect(inputEl.getAttribute('aria-expanded')).toEqual('false');
565+
570566
timePicker.open();
571567
tick();
572568
fixture.detectChanges();
573-
expect(input.getAttribute('aria-expanded')).toEqual('true');
569+
expect(inputEl.getAttribute('aria-expanded')).toEqual('true');
570+
574571
let hour = 8;
575572
let minutes = 42;
576573
let ampm = 0;
577-
hourColumn.children.forEach(el => function () {
574+
hourColumn.children.forEach((el) => {
578575
expect(el.attributes.role).toEqual('spinbutton');
579576
const hours = hour < 10 ? `0${hour}` : `${hour}`;
580-
expect(el.attributes["ariaLabel"]).toEqual(hours);
577+
expect(el.attributes['ariaLabel']).toEqual(hours);
581578
hour++;
582579
});
583-
minutesColumn.children.forEach(el => function () {
580+
minutesColumn.children.forEach((el) => {
584581
expect(el.attributes.role).toEqual('spinbutton');
585-
expect(el.attributes["ariaLabel"]).toEqual(`${minutes}`);
582+
expect(el.attributes['ariaLabel']).toEqual(`${minutes}`);
586583
minutes++;
587584
});
588-
ampmColumn.children.forEach(el => function () {
585+
ampmColumn.children.forEach((el) => {
589586
expect(el.attributes.role).toEqual('spinbutton');
590587
const ampmLabel = ampm === 3 ? 'AM' : ampm === 4 ? 'PM' : null;
591-
expect(el.attributes["ariaLabel"]).toEqual(ampmLabel);
588+
expect(el.attributes['ariaLabel']).toEqual(ampmLabel);
592589
ampm++;
593590
});
591+
594592
timePicker.close();
595-
tick();[[]]
593+
tick();
596594
fixture.detectChanges();
597-
expect(input.getAttribute('aria-expanded')).toEqual('false');
595+
expect(inputEl.getAttribute('aria-expanded')).toEqual('false');
598596
}));
599-
600597
});
601598
});
602599
});

0 commit comments

Comments
 (0)