@@ -9,10 +9,12 @@ import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
99import { IgxSliderType , IgxThumbFromTemplateDirective , IgxThumbToTemplateDirective , IRangeSliderValue , TickLabelsOrientation , TicksOrientation } from './slider.common' ;
1010import { IgxSliderComponent } from './slider.component' ;
1111
12- declare let Simulator : any ;
1312const SLIDER_CLASS = '.igx-slider' ;
13+ const THUMB_TAG = 'igx-thumb' ;
1414const THUMB_TO_CLASS = '.igx-slider-thumb-to' ;
15+ const THUMB_TO_PRESSED_CLASS = '.igx-slider-thumb-to--pressed' ;
1516const THUMB_FROM_CLASS = '.igx-slider-thumb-from' ;
17+ const THUMB_LABEL = 'igx-thumb-label' ;
1618const SLIDER_TICKS_ELEMENT = '.igx-slider__ticks' ;
1719const SLIDER_TICKS_TOP_ELEMENT = '.igx-slider__ticks--top' ;
1820const SLIDER_PRIMARY_GROUP_TICKS_CLASS_NAME = 'igx-slider__ticks-group--tall' ;
@@ -415,46 +417,57 @@ describe('IgxSlider', () => {
415417 expect ( sliderInstance . maxValue ) . toEqual ( expectedMax ) ;
416418 } ) ;
417419
418- it ( 'continuous(smooth) sliding should be allowed' , ( done ) => {
419- pending ( `panRight trigers pointerdown where we are capturing all pointer events by passing a valid pointerId.
420- Pan guesture does not propagate that option. Respectively (no active pointer...) error is thrown.` ) ;
420+ it ( 'continuous(smooth) sliding should be allowed' , async ( ) => {
421421 sliderInstance . continuous = true ;
422+ sliderInstance . thumbLabelVisibilityDuration = 10 ;
422423 fixture . detectChanges ( ) ;
423424
424425 expect ( sliderInstance . continuous ) . toBe ( true ) ;
425426 expect ( sliderInstance . value ) . toBe ( 150 ) ;
426- const sliderEl = fixture . debugElement . query ( By . css ( SLIDER_CLASS ) ) . nativeElement ;
427- sliderEl . dispatchEvent ( new PointerEvent ( 'pointerdown' , { pointerId : 1 , clientX : 200 } ) ) ;
427+ const thumbEl = fixture . debugElement . query ( By . css ( THUMB_TAG ) ) . nativeElement ;
428+ const { x : sliderX , width : sliderWidth } = thumbEl . getBoundingClientRect ( ) ;
429+ const startX = sliderX + sliderWidth / 2 ;
430+
431+ thumbEl . dispatchEvent ( new Event ( 'focus' ) ) ;
428432 fixture . detectChanges ( ) ;
429- expect ( sliderEl ) . toBeDefined ( ) ;
430- return panRight ( sliderEl , sliderEl . offsetHeight , sliderEl . offsetWidth , 200 )
431- . then ( ( ) => {
432- fixture . detectChanges ( ) ;
433- const activeThumb = fixture . debugElement . query ( By . css ( '.igx-slider-thumb-to--active' ) ) ;
434- expect ( sliderInstance . value ) . toBeGreaterThan ( 150 ) ;
435- expect ( activeThumb ) . toBeNull ( ) ;
436- done ( ) ;
437- } ) ;
433+
434+ ( sliderInstance as any ) . onPointerDown ( new PointerEvent ( 'pointerdown' , { pointerId : 1 , clientX : startX } ) ) ;
435+ fixture . detectChanges ( ) ;
436+
437+ ( sliderInstance as any ) . onPointerMove ( new PointerEvent ( 'pointermove' , { pointerId : 1 , clientX : startX + 150 } ) ) ;
438+ fixture . detectChanges ( ) ;
439+ await wait ( ) ;
440+
441+ let activeThumb = fixture . debugElement . query ( By . css ( THUMB_TO_PRESSED_CLASS ) ) ;
442+ expect ( activeThumb ) . not . toBeNull ( ) ;
443+ expect ( sliderInstance . value ) . toBeGreaterThan ( sliderInstance . minValue ) ;
444+
445+ ( sliderInstance as any ) . onPointerMove ( new PointerEvent ( 'pointermove' , { pointerId : 1 , clientX : startX } ) ) ;
446+ fixture . detectChanges ( ) ;
447+ await wait ( ) ;
448+
449+ expect ( sliderInstance . value ) . toEqual ( sliderInstance . minValue ) ;
438450 } ) ;
439451
440- it ( 'should not move thumb slider and value should remain the same when slider is disabled' , ( done ) => {
441- pending ( `panRight trigers pointerdown where we are capturing all pointer events by passing a valid pointerId.
442- Pan guesture does not propagate that option. Respectively (no active pointer...) error is thrown.` ) ;
452+ it ( 'should not move thumb slider and value should remain the same when slider is disabled' , async ( ) => {
443453 sliderInstance . disabled = true ;
444454 fixture . detectChanges ( ) ;
445455
446- const sliderEl = fixture . debugElement . query ( By . css ( SLIDER_CLASS ) ) . nativeElement ;
447- sliderEl . dispatchEvent ( new MouseEvent ( 'mosedown' ) ) ;
456+ const thumbEl = fixture . debugElement . query ( By . css ( THUMB_TAG ) ) . nativeElement ;
457+ const { x : sliderX , width : sliderWidth } = thumbEl . getBoundingClientRect ( ) ;
458+ const startX = sliderX + sliderWidth / 2 ;
459+
460+ thumbEl . dispatchEvent ( new Event ( 'focus' ) ) ;
448461 fixture . detectChanges ( ) ;
449- expect ( sliderEl ) . toBeDefined ( ) ;
450- return panRight ( sliderEl , sliderEl . offsetHeight , sliderEl . offsetWidth , 200 )
451- . then ( ( ) => {
452- fixture . detectChanges ( ) ;
453- const activeThumb = fixture . debugElement . query ( By . css ( '.igx-slider-thumb-to--active' ) ) ;
454- expect ( activeThumb ) . toBeDefined ( ) ;
455- expect ( sliderInstance . value ) . toBe ( sliderInstance . minValue ) ;
456- done ( ) ;
457- } ) ;
462+
463+ ( sliderInstance as any ) . onPointerDown ( new PointerEvent ( 'pointerdown' , { pointerId : 1 , clientX : startX } ) ) ;
464+ fixture . detectChanges ( ) ;
465+
466+ ( sliderInstance as any ) . onPointerMove ( new PointerEvent ( 'pointermove' , { pointerId : 1 , clientX : startX + 150 } ) ) ;
467+ fixture . detectChanges ( ) ;
468+ await wait ( ) ;
469+
470+ expect ( sliderInstance . value ) . toBe ( sliderInstance . minValue ) ;
458471 } ) ;
459472 } ) ;
460473
@@ -474,32 +487,27 @@ describe('IgxSlider', () => {
474487 expect ( ( slider . value as IRangeSliderValue ) . upper ) . toBe ( slider . upperBound ) ;
475488 } ) ;
476489
477- it ( 'continuous(smooth) sliding should be allowed' , ( done ) => {
478- pending ( `panRight trigers pointerdown where we are capturing all pointer events by passing a valid pointerId.
479- Pan guesture does not propagate that option. Respectively (no active pointer...) error is thrown.` ) ;
480- const fromThumb = fixture . debugElement . query ( By . css ( THUMB_FROM_CLASS ) ) . nativeElement ;
490+ it ( 'continuous(smooth) sliding should be allowed' , async ( ) => {
481491 slider . continuous = true ;
482492 fixture . detectChanges ( ) ;
483493
484- expect ( slider . continuous ) . toBe ( true ) ;
494+ const fromThumb = fixture . debugElement . query ( By . css ( THUMB_FROM_CLASS ) ) . nativeElement ;
495+ const { x : sliderX , width : sliderWidth } = fromThumb . getBoundingClientRect ( ) ;
496+ const startX = sliderX + sliderWidth / 2 ;
485497
486- const sliderEl = fixture . debugElement . query ( By . css ( SLIDER_CLASS ) ) . nativeElement ;
487- sliderEl . dispatchEvent ( new PointerEvent ( 'pointerdown' , { pointerId : 1 } ) ) ;
488- fixture . detectChanges ( ) ;
489498 fromThumb . dispatchEvent ( new Event ( 'focus' ) ) ;
490499 fixture . detectChanges ( ) ;
491500
492- expect ( sliderEl ) . toBeDefined ( ) ;
493- return panRight ( sliderEl , sliderEl . offsetHeight , sliderEl . offsetWidth , 200 )
494- . then ( ( ) => {
495- fixture . detectChanges ( ) ;
496- const activetoThumb = fixture . debugElement . query ( By . css ( '.igx-slider-thumb-to--active' ) ) ;
497- const activefromThumb = fixture . debugElement . query ( By . css ( '.igx-slider-thumb-from--active' ) ) ;
498- expect ( slider . value ) . toEqual ( { lower : 60 , upper : 100 } ) ;
499- expect ( activetoThumb ) . toBeNull ( ) ;
500- expect ( activefromThumb ) . toBeNull ( ) ;
501- done ( ) ;
502- } ) ;
501+ ( slider as any ) . onPointerDown ( new PointerEvent ( 'pointerdown' , { pointerId : 1 , clientX : startX } ) ) ;
502+ fixture . detectChanges ( ) ;
503+ await wait ( ) ;
504+
505+ ( slider as any ) . onPointerMove ( new PointerEvent ( 'pointermove' , { pointerId : 1 , clientX : startX + 150 } ) ) ;
506+ fixture . detectChanges ( ) ;
507+ await wait ( ) ;
508+
509+ expect ( ( slider . value as any ) . lower ) . toBeGreaterThan ( slider . minValue ) ;
510+ expect ( ( slider . value as any ) . upper ) . toEqual ( slider . maxValue ) ;
503511 } ) ;
504512
505513 // K.D. Removing this functionality because of 0 benefit and lots of issues.
@@ -1750,8 +1758,8 @@ describe('IgxSlider', () => {
17501758 fix . detectChanges ( ) ;
17511759
17521760 const inst = fix . componentInstance ;
1753- const thumbs = fix . debugElement . queryAll ( By . css ( 'igx-thumb' ) ) ;
1754- const labels = fix . debugElement . queryAll ( By . css ( 'igx-thumb-label' ) ) ;
1761+ const thumbs = fix . debugElement . queryAll ( By . css ( THUMB_TAG ) ) ;
1762+ const labels = fix . debugElement . queryAll ( By . css ( THUMB_LABEL ) ) ;
17551763
17561764 expect ( inst . dir . rtl ) . toEqual ( true ) ;
17571765
@@ -1803,21 +1811,6 @@ describe('IgxSlider', () => {
18031811 } ) ;
18041812 } ) ;
18051813
1806- const panRight = ( element , elementHeight , elementWidth , duration ) => {
1807- const panOptions = {
1808- deltaX : elementWidth * 0.6 ,
1809- clientX : elementWidth * 0.6 ,
1810- deltaY : 0 ,
1811- duration,
1812- pos : [ element . offsetLeft , elementHeight * 0.5 ]
1813- } ;
1814-
1815- return new Promise < void > ( resolve => {
1816- Simulator . gestures . pan ( element , panOptions , ( ) => {
1817- resolve ( null ) ;
1818- } ) ;
1819- } ) ;
1820- } ;
18211814
18221815 const verifySecondaryTicsLabelsAreHidden = ( ticks , hidden ) => {
18231816 const allTicks = Array . from ( ticks . nativeElement . querySelectorAll ( `${ SLIDER_GROUP_TICKS_CLASS } ` ) ) ;
0 commit comments