From 86cdfbfa15e32dc56236dd34ed548e3df7e368b0 Mon Sep 17 00:00:00 2001 From: Aleksandar Kamenov Date: Wed, 12 Dec 2018 14:33:18 +0200 Subject: [PATCH] test(slider): add some tests about the exceeding bounds Closes #2610 --- .../src/lib/slider/slider.component.spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/projects/igniteui-angular/src/lib/slider/slider.component.spec.ts b/projects/igniteui-angular/src/lib/slider/slider.component.spec.ts index b6da2a6bb88..207dd88c4a2 100644 --- a/projects/igniteui-angular/src/lib/slider/slider.component.spec.ts +++ b/projects/igniteui-angular/src/lib/slider/slider.component.spec.ts @@ -321,6 +321,28 @@ describe('IgxSlider', () => { expect(Math.round(slider.value as number)).toBe(60); })); + fit('Value should remain to the max one if it exceeds.', () => { + const fix = TestBed.createComponent(SliderMinMaxComponent); + fix.detectChanges(); + + const slider = fix.componentInstance.slider; + let expectedVal = 150; + let expectedMax = 300; + + expect(slider.value).toEqual(expectedVal); + expect(slider.maxValue).toEqual(expectedMax); + + expectedVal = 250; + expectedMax = 200; + slider.maxValue = expectedMax; + slider.value = expectedVal; + fix.detectChanges(); + + expect(slider.value).not.toEqual(expectedVal); + expect(slider.value).toEqual(expectedMax); + expect(slider.maxValue).toEqual(expectedMax); + }); + function panRight(element, elementHeight, elementWidth, duration) { const panOptions = { deltaX: elementWidth * 0.6, @@ -628,6 +650,27 @@ describe('IgxSlider', () => { expect((slider.value as IRangeSliderValue).upper).toBe(7); }); + fit('Lower and upper bounds should not exceed min and max values', () => { + const fix = TestBed.createComponent(SliderTestComponent); + fix.detectChanges(); + + const componentInst = fix.componentInstance; + const slider = componentInst.slider; + const expectedMinVal = 0; + const expectedMaxVal = 10; + + expect(slider.minValue).toEqual(expectedMinVal); + expect(slider.maxValue).toEqual(expectedMaxVal); + + const expectedLowerBound = -1; + const expectedUpperBound = 11; + slider.lowerBound = expectedLowerBound; + slider.upperBound = expectedUpperBound; + + expect(slider.lowerBound).toEqual(expectedMinVal); + expect(slider.upperBound).toEqual(expectedMaxVal); + }) + describe('EditorProvider', () => { it('Should return correct edit element (single)', () => { const fixture = TestBed.createComponent(SliderInitializeTestComponent);