diff --git a/src/app/components/slider/slider.spec.ts b/src/app/components/slider/slider.spec.ts index 9405572b816..66b9185ebc6 100755 --- a/src/app/components/slider/slider.spec.ts +++ b/src/app/components/slider/slider.spec.ts @@ -3,7 +3,7 @@ import { By } from '@angular/platform-browser'; import { Slider } from './slider'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -describe('Slider', () => { +fdescribe('Slider', () => { let slider: Slider; let fixture: ComponentFixture; @@ -234,6 +234,31 @@ describe('Slider', () => { expect(unbindDragListenersSpy).toHaveBeenCalled(); }); + it('should change values with keyboard events', () => { + slider.updateValue(0); + fixture.detectChanges(); + + const incrementValueSpy = spyOn(slider, 'incrementValue').and.callThrough(); + const spanEl = fixture.debugElement.query(By.css('.p-slider-handle')); + spanEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'ArrowRight' })); + spanEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'ArrowRight' })); + fixture.detectChanges(); + expect(incrementValueSpy).toHaveBeenCalled(); + + const decrementValueSpy = spyOn(slider, 'decrementValue').and.callThrough(); + spanEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'ArrowLeft' })); + fixture.detectChanges(); + expect(decrementValueSpy).toHaveBeenCalled(); + + const onDragEndSpy = spyOn(slider, 'onDragEnd').and.callThrough(); + const onSlideEndEmitterSpy = spyOn(slider.onSlideEnd, 'emit').and.callThrough(); + spanEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'Tab' })); + fixture.detectChanges(); + expect(onDragEndSpy).toHaveBeenCalled(); + expect(onSlideEndEmitterSpy).toHaveBeenCalled(); + expect(slider.value).toEqual(1); + }); + it('should increment value with step', () => { slider.value = 0; slider.step = 2;