Commit d0a5b769 authored by Valentin Hervieu's avatar Valentin Hervieu

test(minRange): Add test coverage for minRange option

parent 1e5a483c
......@@ -2120,7 +2120,6 @@ describe('rzslider - ', function() {
slider.callOnChange.called.should.be.true;
});
});
});
describe('range vertical slider - ', function() {
beforeEach(function() {
......@@ -2652,7 +2651,7 @@ describe('rzslider - ', function() {
});
});
describe('single horizontal slider - ', function() {
describe('single horizontal slider with onlyBindHandles - ', function() {
beforeEach(function() {
var sliderConf = {
value: 0,
......@@ -2696,6 +2695,59 @@ describe('rzslider - ', function() {
});
});
describe('single horizontal slider with onlyBindHandles - ', function() {
beforeEach(function() {
var sliderConf = {
min: 45,
max: 55,
options: {
floor: 0,
ceil: 100,
minRange: 10
}
};
createRangeSlider(sliderConf);
});
afterEach(function() {
// to clean document listener
fireMouseup();
});
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
fireMousedown(slider.minH, 0);
var expectedValue = 50,
offset = slider.valueToOffset(expectedValue) + slider.handleHalfDim + slider.sliderElem.rzsp;
fireMousemove(offset);
expect(scope.slider.min).to.equal(45);
});
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
fireMousedown(slider.maxH, 0);
var expectedValue = 50,
offset = slider.valueToOffset(expectedValue) + slider.handleHalfDim + slider.sliderElem.rzsp;
fireMousemove(offset);
expect(scope.slider.max).to.equal(55);
});
it('should modify the min value if new range is larger than minRange when moving minH', function() {
fireMousedown(slider.minH, 0);
var expectedValue = 30,
offset = slider.valueToOffset(expectedValue) + slider.handleHalfDim + slider.sliderElem.rzsp;
fireMousemove(offset);
expect(scope.slider.min).to.equal(expectedValue);
});
it('should modify the max value if new range is larger than than minRange when moving maxH', function() {
fireMousedown(slider.maxH, 0);
var expectedValue = 70,
offset = slider.valueToOffset(expectedValue) + slider.handleHalfDim + slider.sliderElem.rzsp;
fireMousemove(offset);
expect(scope.slider.max).to.equal(expectedValue);
});
});
});
/*
******************************************************************************
KEYBOARD CONTROLS
......@@ -3114,19 +3166,51 @@ describe('rzslider - ', function() {
expect(scope.slider.value).to.equal(10);
});
it('should not be modified by keyboard if keyboardSupport=false', function() {
it('should not be modified by keyboard if new range is below minRange', function() {
var sliderConf = {
value: 10,
min: 45,
max: 55,
options: {
floor: 0,
ceil: 100,
keyboardSupport: false
step: 1,
minRange: 10
}
};
createSlider(sliderConf);
createRangeSlider(sliderConf);
//try to move minH right
slider.minH.triggerHandler('focus');
pressKeydown(slider.minH, 'RIGHT');
expect(scope.slider.min).to.equal(45);
//try to move maxH left
slider.maxH.triggerHandler('focus');
pressKeydown(slider.maxH, 'LEFT');
expect(scope.slider.max).to.equal(55);
});
it('should be modified by keyboard if new range is above minRange', function() {
var sliderConf = {
min: 45,
max: 55,
options: {
floor: 0,
ceil: 100,
step: 1,
minRange: 10
}
};
createRangeSlider(sliderConf);
//try to move minH left
slider.minH.triggerHandler('focus');
pressKeydown(slider.minH, 'LEFT');
expect(scope.slider.value).to.equal(10);
expect(scope.slider.min).to.equal(44);
//try to move maxH right
slider.maxH.triggerHandler('focus');
pressKeydown(slider.maxH, 'RIGHT');
expect(scope.slider.max).to.equal(56);
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment