Skip to content

Commit 0321b4f

Browse files
committed
test(time-picker): add pan event test#9717
1 parent 4ce66eb commit 0321b4f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import { IgxToggleDirective } from '../directives/toggle/toggle.directive';
1515
import { PlatformUtil } from '../core/utils';
1616
import { DatePart, IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api';
1717
import { DateTimeUtil } from '../date-common/util/date-time.util';
18-
import { IgxTimeItemDirective } from './time-picker.directives';
18+
import { IgxItemListDirective, IgxTimeItemDirective } from './time-picker.directives';
1919
import { IgxPickerClearComponent, IgxPickerToggleComponent } from '../date-common/public_api';
2020
import { Subscription } from 'rxjs';
21+
import { HammerGesturesManager } from '../core/touch';
2122

2223
const CSS_CLASS_TIMEPICKER = 'igx-time-picker';
2324
const CSS_CLASS_INPUTGROUP = 'igx-input-group';
@@ -435,6 +436,26 @@ describe('IgxTimePicker', () => {
435436
date.setHours(20);
436437
expect(timePicker.validate(mockFormControl)).toEqual({ maxValue: true });
437438
});
439+
440+
it('should handle panmove event correctly', () => {
441+
const touchManager = new HammerGesturesManager(null, null, new PlatformUtil(1));
442+
const itemListDirective = new IgxItemListDirective(timePicker, elementRef, touchManager);
443+
spyOn(touchManager, 'addEventListener');
444+
445+
itemListDirective.ngOnInit();
446+
expect(touchManager.addEventListener).toHaveBeenCalledTimes(1);
447+
const hammerOptions: HammerOptions = { recognizers: [[Hammer.Pan, { direction: Hammer.DIRECTION_VERTICAL, threshold: 5 }]] };
448+
expect(touchManager.addEventListener).toHaveBeenCalledWith(
449+
elementRef.nativeElement,
450+
'pan',
451+
(itemListDirective as any).onPanMove,
452+
hammerOptions);
453+
454+
spyOn<any>(itemListDirective, 'onPanMove').and.callThrough();
455+
const event = { type: 'pan' };
456+
(itemListDirective as any).onPanMove(event);
457+
expect(itemListDirective['onPanMove']).toHaveBeenCalled();
458+
});
438459
});
439460

440461
describe('Interaction tests', () => {

0 commit comments

Comments
 (0)