Skip to content

Commit de16797

Browse files
committed
test(time-picker): fix failing tests #6482
1 parent cf38e58 commit de16797

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { PickerInteractionMode } from '../date-common/types';
1111
import { IgxIconModule } from '../icon/public_api';
1212
import { IgxToggleDirective } from '../directives/toggle/toggle.directive';
1313
import { PlatformUtil } from '../core/utils';
14-
import { DatePart } from '../directives/date-time-editor/public_api';
14+
import { DatePart, IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api';
1515
import { DateTimeUtil } from '../date-common/util/date-time.util';
1616

1717
const CSS_CLASS_TIMEPICKER = 'igx-time-picker';
@@ -182,7 +182,7 @@ describe('IgxTimePicker', () => {
182182

183183
describe('Interaction tests', () => {
184184
let fixture: ComponentFixture<any>;
185-
let timePickerElement: any;
185+
let timePickerElement: DebugElement;
186186
let inputGroup: DebugElement;
187187
let input: DebugElement;
188188
let hourColumn: DebugElement;
@@ -210,9 +210,9 @@ describe('IgxTimePicker', () => {
210210
fixture = TestBed.createComponent(IgxTimePickerTestComponent);
211211
fixture.detectChanges();
212212
timePicker = fixture.componentInstance.timePicker;
213-
timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)).nativeElement;
213+
timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER));
214214
inputGroup = fixture.debugElement.query(By.css(`.${CSS_CLASS_INPUTGROUP}`));
215-
input = fixture.debugElement.query(By.css(`.${CSS_CLASS_INPUT}`));
215+
input = fixture.debugElement.query(By.css(CSS_CLASS_INPUT));
216216
hourColumn = fixture.debugElement.query(By.css(CSS_CLASS_HOURLIST));
217217
toggleDirectiveElement = fixture.debugElement.query(By.directive(IgxToggleDirective));
218218
toggleDirective = toggleDirectiveElement.injector.get(IgxToggleDirective) as IgxToggleDirective;
@@ -237,7 +237,7 @@ describe('IgxTimePicker', () => {
237237
}));
238238

239239
it('should open the dropdown with `ArrowDown` + `Alt` key press and close it on outside click', fakeAsync(() => {
240-
input.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', altKey: true }));
240+
UIInteractions.triggerEventHandlerKeyDown('ArrowDown', timePickerElement, true);
241241
tick();
242242
fixture.detectChanges();
243243
expect(toggleDirective.collapsed).toBeFalsy();
@@ -281,7 +281,7 @@ describe('IgxTimePicker', () => {
281281
}));
282282

283283
it('should open/close the dropdown and keep the current selection on Space/Enter key press', fakeAsync(() => {
284-
UIInteractions.triggerKeyDownEvtUponElem('Space', input.nativeElement, true);
284+
UIInteractions.triggerEventHandlerKeyDown(' ', timePickerElement);
285285
tick();
286286
fixture.detectChanges();
287287
expect(toggleDirective.collapsed).toBeFalsy();
@@ -314,7 +314,7 @@ describe('IgxTimePicker', () => {
314314
hourColumn.triggerEventHandler('wheel', event);
315315
fixture.detectChanges(); hourColumn.triggerEventHandler('wheel', event);
316316
fixture.detectChanges();
317-
const selectedHour = fixture.componentInstance.date.getHours() - 3;
317+
const selectedHour = fixture.componentInstance.date.getHours() + 2;
318318
expect((timePicker.value as Date).getHours()).toEqual(selectedHour);
319319

320320
UIInteractions.triggerKeyDownEvtUponElem('Escape', input.nativeElement, true);
@@ -646,8 +646,7 @@ describe('IgxTimePicker', () => {
646646
template: `
647647
<igx-time-picker #picker [value]="date" [mode]="mode" [minValue]="minValue" [maxValue]="maxValue">
648648
<label igxLabel>Select time</label>
649-
</igx-time-picker>
650-
`
649+
</igx-time-picker>`
651650
})
652651
export class IgxTimePickerTestComponent {
653652
@ViewChild('picker', { read: IgxTimePickerComponent, static: true })

0 commit comments

Comments
 (0)