+
+
-
-
-
+
+
+
+
+
+
test- {{floorLabel}}
diff --git a/tests/specs/helper-functions-test.js b/tests/specs/helper-functions-test.js
index 353b325..307a15f 100644
--- a/tests/specs/helper-functions-test.js
+++ b/tests/specs/helper-functions-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Helper functions - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
describe('tests with same config', function() {
beforeEach(function() {
@@ -27,393 +29,417 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should have a valid roundStep for integer values when floor is 0', function() {
- expect(helper.slider.roundStep(10)).to.equal(10);
- expect(helper.slider.roundStep(9)).to.equal(10);
- expect(helper.slider.roundStep(11)).to.equal(10);
- expect(helper.slider.roundStep(15)).to.equal(20);
- expect(helper.slider.roundStep(14)).to.equal(10);
- expect(helper.slider.roundStep(-10)).to.equal(-10);
- expect(helper.slider.roundStep(-9)).to.equal(-10);
- expect(helper.slider.roundStep(-11)).to.equal(-10);
- expect(helper.slider.roundStep(-16)).to.equal(-20);
- expect(helper.slider.roundStep(-15)).to.equal(-10);
- expect(helper.slider.roundStep(-14)).to.equal(-10);
- });
+ expect(helper.slider.roundStep(10)).to.equal(10)
+ expect(helper.slider.roundStep(9)).to.equal(10)
+ expect(helper.slider.roundStep(11)).to.equal(10)
+ expect(helper.slider.roundStep(15)).to.equal(20)
+ expect(helper.slider.roundStep(14)).to.equal(10)
+ expect(helper.slider.roundStep(-10)).to.equal(-10)
+ expect(helper.slider.roundStep(-9)).to.equal(-10)
+ expect(helper.slider.roundStep(-11)).to.equal(-10)
+ expect(helper.slider.roundStep(-16)).to.equal(-20)
+ expect(helper.slider.roundStep(-15)).to.equal(-10)
+ expect(helper.slider.roundStep(-14)).to.equal(-10)
+ })
it('should have a valid roundStep for integer values when floor is above 0', function() {
- helper.scope.slider.options.floor = 3;
- helper.scope.slider.options.ceil = 103;
- helper.scope.$digest();
-
- expect(helper.slider.roundStep(3)).to.equal(3);
- expect(helper.slider.roundStep(13)).to.equal(13);
- expect(helper.slider.roundStep(12)).to.equal(13);
- expect(helper.slider.roundStep(14)).to.equal(13);
- expect(helper.slider.roundStep(18)).to.equal(23);
- expect(helper.slider.roundStep(17)).to.equal(13);
- });
+ helper.scope.slider.options.floor = 3
+ helper.scope.slider.options.ceil = 103
+ helper.scope.$digest()
+
+ expect(helper.slider.roundStep(3)).to.equal(3)
+ expect(helper.slider.roundStep(13)).to.equal(13)
+ expect(helper.slider.roundStep(12)).to.equal(13)
+ expect(helper.slider.roundStep(14)).to.equal(13)
+ expect(helper.slider.roundStep(18)).to.equal(23)
+ expect(helper.slider.roundStep(17)).to.equal(13)
+ })
it('should have a valid roundStep for integer values when floor is below 0', function() {
- helper.scope.slider.options.floor = -25;
- helper.scope.$digest();
-
- expect(helper.slider.roundStep(-5)).to.equal(-5);
- expect(helper.slider.roundStep(-15)).to.equal(-15);
- expect(helper.slider.roundStep(-16)).to.equal(-15);
- expect(helper.slider.roundStep(-14)).to.equal(-15);
- expect(helper.slider.roundStep(-21)).to.equal(-25);
- expect(helper.slider.roundStep(-20)).to.equal(-15);
- expect(helper.slider.roundStep(-19)).to.equal(-15);
- });
+ helper.scope.slider.options.floor = -25
+ helper.scope.$digest()
+
+ expect(helper.slider.roundStep(-5)).to.equal(-5)
+ expect(helper.slider.roundStep(-15)).to.equal(-15)
+ expect(helper.slider.roundStep(-16)).to.equal(-15)
+ expect(helper.slider.roundStep(-14)).to.equal(-15)
+ expect(helper.slider.roundStep(-21)).to.equal(-25)
+ expect(helper.slider.roundStep(-20)).to.equal(-15)
+ expect(helper.slider.roundStep(-19)).to.equal(-15)
+ })
it('should have a valid roundStep for floating values when floor is 0', function() {
- helper.scope.slider.options.precision = 1;
- helper.scope.slider.options.step = 0.1;
- helper.scope.$digest();
-
- expect(helper.slider.roundStep(10)).to.equal(10);
- expect(helper.slider.roundStep(1.1)).to.equal(1.1);
- expect(helper.slider.roundStep(1.09)).to.equal(1.1);
- expect(helper.slider.roundStep(1.11)).to.equal(1.1);
- expect(helper.slider.roundStep(1.15)).to.equal(1.2);
- expect(helper.slider.roundStep(1.14)).to.equal(1.1);
-
- expect(helper.slider.roundStep(-10)).to.equal(-10);
- expect(helper.slider.roundStep(-1.1)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.09)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.11)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.16)).to.equal(-1.2);
- expect(helper.slider.roundStep(-1.15)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.14)).to.equal(-1.1);
- });
+ helper.scope.slider.options.precision = 1
+ helper.scope.slider.options.step = 0.1
+ helper.scope.$digest()
+
+ expect(helper.slider.roundStep(10)).to.equal(10)
+ expect(helper.slider.roundStep(1.1)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.09)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.11)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.15)).to.equal(1.2)
+ expect(helper.slider.roundStep(1.14)).to.equal(1.1)
+
+ expect(helper.slider.roundStep(-10)).to.equal(-10)
+ expect(helper.slider.roundStep(-1.1)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.09)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.11)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.16)).to.equal(-1.2)
+ expect(helper.slider.roundStep(-1.15)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.14)).to.equal(-1.1)
+ })
it('should have a valid roundStep for floating values when floor is above 0', function() {
- helper.scope.slider.options.floor = 3;
- helper.scope.slider.options.ceil = 103;
- helper.scope.slider.options.precision = 1;
- helper.scope.slider.options.step = 0.1;
- helper.scope.$digest();
-
- expect(helper.slider.roundStep(3)).to.equal(3);
- expect(helper.slider.roundStep(13)).to.equal(13);
- expect(helper.slider.roundStep(1.1)).to.equal(1.1);
- expect(helper.slider.roundStep(1.09)).to.equal(1.1);
- expect(helper.slider.roundStep(1.11)).to.equal(1.1);
- expect(helper.slider.roundStep(1.15)).to.equal(1.2);
- expect(helper.slider.roundStep(1.14)).to.equal(1.1);
- });
+ helper.scope.slider.options.floor = 3
+ helper.scope.slider.options.ceil = 103
+ helper.scope.slider.options.precision = 1
+ helper.scope.slider.options.step = 0.1
+ helper.scope.$digest()
+
+ expect(helper.slider.roundStep(3)).to.equal(3)
+ expect(helper.slider.roundStep(13)).to.equal(13)
+ expect(helper.slider.roundStep(1.1)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.09)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.11)).to.equal(1.1)
+ expect(helper.slider.roundStep(1.15)).to.equal(1.2)
+ expect(helper.slider.roundStep(1.14)).to.equal(1.1)
+ })
it('should have a valid roundStep for floating values when floor is below 0', function() {
- helper.scope.slider.options.floor = -25;
- helper.scope.slider.options.ceil = 75;
- helper.scope.slider.options.precision = 1;
- helper.scope.slider.options.step = 0.1;
- helper.scope.$digest();
-
- expect(helper.slider.roundStep(-25)).to.equal(-25);
- expect(helper.slider.roundStep(-5)).to.equal(-5);
- expect(helper.slider.roundStep(-1.1)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.09)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.11)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.16)).to.equal(-1.2);
- expect(helper.slider.roundStep(-1.15)).to.equal(-1.1);
- expect(helper.slider.roundStep(-1.14)).to.equal(-1.1);
- });
+ helper.scope.slider.options.floor = -25
+ helper.scope.slider.options.ceil = 75
+ helper.scope.slider.options.precision = 1
+ helper.scope.slider.options.step = 0.1
+ helper.scope.$digest()
+
+ expect(helper.slider.roundStep(-25)).to.equal(-25)
+ expect(helper.slider.roundStep(-5)).to.equal(-5)
+ expect(helper.slider.roundStep(-1.1)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.09)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.11)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.16)).to.equal(-1.2)
+ expect(helper.slider.roundStep(-1.15)).to.equal(-1.1)
+ expect(helper.slider.roundStep(-1.14)).to.equal(-1.1)
+ })
it('should have a valid hideEl', function() {
- var el = angular.element('
');
- helper.slider.hideEl(el);
- expect(el.css('visibility')).to.equal('hidden');
- });
+ var el = angular.element('
')
+ helper.slider.hideEl(el)
+ expect(el.css('visibility')).to.equal('hidden')
+ })
it('should have a valid showEl when not rzAlwaysHide', function() {
- var el = angular.element('
');
- helper.slider.showEl(el);
- expect(el.css('visibility')).to.equal('visible');
- });
+ var el = angular.element('
')
+ helper.slider.showEl(el)
+ expect(el.css('visibility')).to.equal('visible')
+ })
it('should have a valid showEl when rzAlwaysHide', function() {
- var el = angular.element('
');
- el.css('visibility', 'hidden');
- el.rzAlwaysHide = true;
+ var el = angular.element('
')
+ el.css('visibility', 'hidden')
+ el.rzAlwaysHide = true
- helper.slider.showEl(el);
- expect(el.css('visibility')).to.equal('hidden');
- });
+ helper.slider.showEl(el)
+ expect(el.css('visibility')).to.equal('hidden')
+ })
it('should have a valid setPosition for horizontal sliders', function() {
- var el = angular.element('
');
- helper.slider.setPosition(el, 12);
- expect(el.css('left')).to.equal('12px');
- });
+ var el = angular.element('
')
+ helper.slider.setPosition(el, 12)
+ expect(el.css('left')).to.equal('12px')
+ })
it('should have a valid setPosition for vertical sliders', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- var el = angular.element('
');
- helper.slider.setPosition(el, 12);
- expect(el.css('bottom')).to.equal('12px');
- });
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ var el = angular.element('
')
+ helper.slider.setPosition(el, 12)
+ expect(el.css('bottom')).to.equal('12px')
+ })
it('should have a valid getDimension for horizontal sliders', function() {
- expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(1000);
- });
+ expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(
+ 1000
+ )
+ })
it('should have a valid getDimension for horizontal sliders with custom scale', function() {
- helper.scope.slider.options.scale = 2;
- helper.scope.$digest();
- expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(2000);
- });
+ helper.scope.slider.options.scale = 2
+ helper.scope.$digest()
+ expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(
+ 2000
+ )
+ })
it('should have a valid getDimension for vertical sliders', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(1000);
- });
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(
+ 1000
+ )
+ })
it('should have a valid getDimension for vertical sliders with custom scale', function() {
- helper.scope.slider.options.scale = 2;
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(2000);
- });
+ helper.scope.slider.options.scale = 2
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ expect(helper.slider.getDimension(helper.slider.sliderElem)).to.equal(
+ 2000
+ )
+ })
it('should have a valid setDimension for horizontal sliders', function() {
- var el = angular.element('
');
- helper.slider.setDimension(el, 12);
- expect(el.css('width')).to.equal('12px');
- });
+ var el = angular.element('
')
+ helper.slider.setDimension(el, 12)
+ expect(el.css('width')).to.equal('12px')
+ })
it('should have a valid setDimension for vertical sliders', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- var el = angular.element('
');
- helper.slider.setDimension(el, 12);
- expect(el.css('height')).to.equal('12px');
- });
-
- it('should have a valid valueToOffset for positive sliders', function() {
- helper.slider.maxPos = 1000;
- expect(helper.slider.valueToOffset(0)).to.equal(0);
- expect(helper.slider.valueToOffset(50)).to.equal(500);
- expect(helper.slider.valueToOffset(100)).to.equal(1000);
- });
-
- it('should have a valid valueToOffset for negative sliders', function() {
- helper.scope.slider.options.floor = -100;
- helper.scope.slider.options.ceil = 0;
- helper.scope.slider.value = -50;
- helper.scope.$digest();
-
- helper.slider.maxPos = 1000;
- expect(helper.slider.valueToOffset(0)).to.equal(1000);
- expect(helper.slider.valueToOffset(-50)).to.equal(500);
- expect(helper.slider.valueToOffset(-100)).to.equal(0);
- });
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ var el = angular.element('
')
+ helper.slider.setDimension(el, 12)
+ expect(el.css('height')).to.equal('12px')
+ })
+
+ it('should have a valid valueToPosition for positive sliders', function() {
+ helper.slider.maxPos = 1000
+ expect(helper.slider.valueToPosition(0)).to.equal(0)
+ expect(helper.slider.valueToPosition(50)).to.equal(500)
+ expect(helper.slider.valueToPosition(100)).to.equal(1000)
+ })
+
+ it('should have a valid valueToPosition for negative sliders', function() {
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = 0
+ helper.scope.slider.value = -50
+ helper.scope.$digest()
+
+ helper.slider.maxPos = 1000
+ expect(helper.slider.valueToPosition(0)).to.equal(1000)
+ expect(helper.slider.valueToPosition(-50)).to.equal(500)
+ expect(helper.slider.valueToPosition(-100)).to.equal(0)
+ })
it('should have a valid sanitizeValue', function() {
- expect(helper.slider.sanitizeValue(0)).to.equal(0);
- expect(helper.slider.sanitizeValue(50)).to.equal(50);
- expect(helper.slider.sanitizeValue(100)).to.equal(100);
- expect(helper.slider.sanitizeValue(-1)).to.equal(0);
- expect(helper.slider.sanitizeValue(-10)).to.equal(0);
- expect(helper.slider.sanitizeValue(101)).to.equal(100);
- expect(helper.slider.sanitizeValue(110)).to.equal(100);
- });
-
- it('should have a valid offsetToValue for positive sliders', function() {
- helper.slider.maxPos = 1000;
- expect(helper.slider.offsetToValue(0)).to.equal(0);
- expect(helper.slider.offsetToValue(1000)).to.equal(100);
- expect(helper.slider.offsetToValue(500)).to.equal(50);
- });
-
- it('should have a valid offsetToValue for for negative sliders', function() {
- helper.scope.slider.options.floor = -100;
- helper.scope.slider.options.ceil = 0;
- helper.scope.slider.value = -50;
- helper.scope.$digest();
- helper.slider.maxPos = 1000;
-
- expect(helper.slider.offsetToValue(0)).to.equal(-100);
- expect(helper.slider.offsetToValue(1000)).to.equal(0);
- expect(helper.slider.offsetToValue(500)).to.equal(-50);
- });
+ expect(helper.slider.sanitizeValue(0)).to.equal(0)
+ expect(helper.slider.sanitizeValue(50)).to.equal(50)
+ expect(helper.slider.sanitizeValue(100)).to.equal(100)
+ expect(helper.slider.sanitizeValue(-1)).to.equal(0)
+ expect(helper.slider.sanitizeValue(-10)).to.equal(0)
+ expect(helper.slider.sanitizeValue(101)).to.equal(100)
+ expect(helper.slider.sanitizeValue(110)).to.equal(100)
+ })
+
+ it('should have a valid positionToValue for positive sliders', function() {
+ helper.slider.maxPos = 1000
+ expect(helper.slider.positionToValue(0)).to.equal(0)
+ expect(helper.slider.positionToValue(1000)).to.equal(100)
+ expect(helper.slider.positionToValue(500)).to.equal(50)
+ })
+
+ it('should have a valid positionToValue for for negative sliders', function() {
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = 0
+ helper.scope.slider.value = -50
+ helper.scope.$digest()
+ helper.slider.maxPos = 1000
+
+ expect(helper.slider.positionToValue(0)).to.equal(-100)
+ expect(helper.slider.positionToValue(1000)).to.equal(0)
+ expect(helper.slider.positionToValue(500)).to.equal(-50)
+ })
it('should have a valid getEventXY for horizontal sliders on desktop browsers', function() {
var event = {
- clientX: 12
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ clientX: 12,
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventXY for vertical sliders on desktop browsers', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
var event = {
- clientY: 12
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ clientY: 12,
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventXY for horizontal sliders on mobile browsers with no originalEvent', function() {
var event = {
- touches: [{
- clientX: 12
- }]
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ touches: [
+ {
+ clientX: 12,
+ },
+ ],
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventXY for horizontal sliders on mobile browsers with originalEvent', function() {
var event = {
originalEvent: {
- touches: [{
- clientX: 12
- }]
- }
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ touches: [
+ {
+ clientX: 12,
+ },
+ ],
+ },
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventXY for vertical sliders on mobile browsers with no originalEvent', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
var event = {
- touches: [{
- clientY: 12
- }]
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ touches: [
+ {
+ clientY: 12,
+ },
+ ],
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventXY for vertical sliders on mobile browsers with originalEvent', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
var event = {
originalEvent: {
- touches: [{
- clientY: 12
- }]
- }
- };
- expect(helper.slider.getEventXY(event)).to.equal(12);
- });
+ touches: [
+ {
+ clientY: 12,
+ },
+ ],
+ },
+ }
+ expect(helper.slider.getEventXY(event)).to.equal(12)
+ })
it('should have a valid getEventPosition for horizontal sliders', function() {
- sinon.stub(helper.slider, 'getEventXY').returns(46);
- var event = {};
+ sinon.stub(helper.slider, 'getEventXY').returns(46)
+ var event = {}
//fake slider's dimension
- helper.slider.sliderElem.rzsp = 10;
- helper.slider.handleHalfDim = 16;
+ helper.slider.sliderElem.rzsp = 10
+ helper.slider.handleHalfDim = 16
- expect(helper.slider.getEventPosition(event)).to.equal(20);
- });
+ expect(helper.slider.getEventPosition(event)).to.equal(20)
+ })
it('should have a valid getEventPosition for vertical sliders', function() {
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- sinon.stub(helper.slider, 'getEventXY').returns(46);
- var event = {};
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ sinon.stub(helper.slider, 'getEventXY').returns(46)
+ var event = {}
//fake slider's dimension
- helper.slider.sliderElem.rzsp = 10;
- helper.slider.handleHalfDim = 16;
+ helper.slider.sliderElem.rzsp = 10
+ helper.slider.handleHalfDim = 16
- expect(helper.slider.getEventPosition(event)).to.equal(-52);
- });
+ expect(helper.slider.getEventPosition(event)).to.equal(-52)
+ })
it('should have a valid getEventPosition for horizontal sliders with scale option', function() {
- helper.scope.slider.options.scale = 0.5;
- helper.scope.$digest();
- sinon.stub(helper.slider, 'getEventXY').returns(46);
- var event = {};
+ helper.scope.slider.options.scale = 0.5
+ helper.scope.$digest()
+ sinon.stub(helper.slider, 'getEventXY').returns(46)
+ var event = {}
//fake slider's dimension
- helper.slider.sliderElem.rzsp = 10;
- helper.slider.handleHalfDim = 16;
+ helper.slider.sliderElem.rzsp = 10
+ helper.slider.handleHalfDim = 16
- expect(helper.slider.getEventPosition(event)).to.equal(10);
- });
+ expect(helper.slider.getEventPosition(event)).to.equal(2)
+ })
it('should have a valid getEventPosition for vertical sliders with scale option', function() {
- helper.scope.slider.options.scale = 0.5;
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- sinon.stub(helper.slider, 'getEventXY').returns(46);
- var event = {};
+ helper.scope.slider.options.scale = 0.5
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ sinon.stub(helper.slider, 'getEventXY').returns(46)
+ var event = {}
//fake slider's dimension
- helper.slider.sliderElem.rzsp = 10;
- helper.slider.handleHalfDim = 16;
+ helper.slider.sliderElem.rzsp = 10
+ helper.slider.handleHalfDim = 16
- expect(helper.slider.getEventPosition(event)).to.equal(-26);
- });
+ expect(helper.slider.getEventPosition(event)).to.equal(-34)
+ })
it('should have a valid getEventNames for desktop', function() {
var event = {
clientX: 10,
- clientY: 100
- };
- var eventNames = helper.slider.getEventNames(event);
+ clientY: 100,
+ }
+ var eventNames = helper.slider.getEventNames(event)
expect(eventNames).to.deep.equal({
moveEvent: 'mousemove',
- endEvent: 'mouseup'
- });
- });
+ endEvent: 'mouseup',
+ })
+ })
it('should have a valid getEventNames for mobile with new API', function() {
var event = {
- touches: [{
- clientX: 10,
- clientY: 100
- }]
- };
- var eventNames = helper.slider.getEventNames(event);
+ touches: [
+ {
+ clientX: 10,
+ clientY: 100,
+ },
+ ],
+ }
+ var eventNames = helper.slider.getEventNames(event)
expect(eventNames).to.deep.equal({
moveEvent: 'touchmove',
- endEvent: 'touchend'
- });
- });
+ endEvent: 'touchend',
+ })
+ })
it('should have a valid getEventNames for mobile with old API', function() {
var event = {
originalEvent: {
- touches: [{
- clientX: 10,
- clientY: 100
- }]
- }
- };
- var eventNames = helper.slider.getEventNames(event);
+ touches: [
+ {
+ clientX: 10,
+ clientY: 100,
+ },
+ ],
+ },
+ }
+ var eventNames = helper.slider.getEventNames(event)
expect(eventNames).to.deep.equal({
moveEvent: 'touchmove',
- endEvent: 'touchend'
- });
- });
+ endEvent: 'touchend',
+ })
+ })
it('should have a valid getNearestHandle for single sliders', function() {
- sinon.stub(helper.slider, 'getEventPosition').returns(46);
- var event = {};
- expect(helper.slider.getNearestHandle(event)).to.equal(helper.slider.minH);
- });
+ sinon.stub(helper.slider, 'getEventPosition').returns(46)
+ var event = {}
+ expect(helper.slider.getNearestHandle(event)).to.equal(
+ helper.slider.minH
+ )
+ })
it('should have a valid focusElement', function() {
- var el = [{
- focus: sinon.spy()
- }];
- helper.slider.focusElement(el);
- el[0].focus.called.should.be.true;
- });
- });
+ var el = [
+ {
+ focus: sinon.spy(),
+ },
+ ]
+ helper.slider.focusElement(el)
+ el[0].focus.called.should.be.true
+ })
+ })
describe('Tests with specific config', function() {
it('should have a valid getNearestHandle for range sliders when click is near minH', function() {
@@ -423,19 +449,21 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- sinon.stub(helper.slider, 'getEventPosition').returns(46);
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ sinon.stub(helper.slider, 'getEventPosition').returns(46)
//fake slider's dimension
- helper.slider.minH.rzsp = 0;
- helper.slider.maxH.rzsp = 100;
+ helper.slider.minH.rzsp = 0
+ helper.slider.maxH.rzsp = 100
- var event = {};
- expect(helper.slider.getNearestHandle(event)).to.equal(helper.slider.minH);
- });
+ var event = {}
+ expect(helper.slider.getNearestHandle(event)).to.equal(
+ helper.slider.minH
+ )
+ })
it('should have a valid getNearestHandle for range sliders when click is near maxH', function() {
var sliderConf = {
@@ -444,19 +472,21 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- sinon.stub(helper.slider, 'getEventPosition').returns(66);
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ sinon.stub(helper.slider, 'getEventPosition').returns(66)
//fake slider's dimension
- helper.slider.minH.rzsp = 0;
- helper.slider.maxH.rzsp = 100;
+ helper.slider.minH.rzsp = 0
+ helper.slider.maxH.rzsp = 100
- var event = {};
- expect(helper.slider.getNearestHandle(event)).to.equal(helper.slider.maxH);
- });
+ var event = {}
+ expect(helper.slider.getNearestHandle(event)).to.equal(
+ helper.slider.maxH
+ )
+ })
it('should have a bindEvents that bind correct events for single sliders on desktop', function() {
var sliderConf = {
@@ -464,42 +494,42 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.onStart = sinon.spy();
- helper.slider.onMove = sinon.spy();
- helper.slider.onPointerFocus = sinon.spy();
-
- helper.slider.unbindEvents(); //remove previously bound events
- helper.slider.bindEvents();
-
- helper.slider.selBar.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(1);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.minH.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.maxH.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.fullBar.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(3);
- expect(helper.slider.onMove.callCount).to.equal(2);
-
- helper.slider.ticks.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(4);
- expect(helper.slider.onMove.callCount).to.equal(3);
-
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.onPointerFocus.callCount).to.equal(1);
- helper.slider.maxH.triggerHandler('focus');
- expect(helper.slider.onPointerFocus.callCount).to.equal(1);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.onStart = sinon.spy()
+ helper.slider.onMove = sinon.spy()
+ helper.slider.onPointerFocus = sinon.spy()
+
+ helper.slider.unbindEvents() //remove previously bound events
+ helper.slider.bindEvents()
+
+ helper.slider.selBar.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(1)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.minH.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.maxH.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.fullBar.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(3)
+ expect(helper.slider.onMove.callCount).to.equal(2)
+
+ helper.slider.ticks.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(4)
+ expect(helper.slider.onMove.callCount).to.equal(3)
+
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.onPointerFocus.callCount).to.equal(1)
+ helper.slider.maxH.triggerHandler('focus')
+ expect(helper.slider.onPointerFocus.callCount).to.equal(1)
+ })
it('should have a bindEvents that bind correct events for single sliders on mobile', function() {
var sliderConf = {
@@ -507,37 +537,37 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.onStart = sinon.spy();
- helper.slider.onMove = sinon.spy();
- helper.slider.onPointerFocus = sinon.spy();
-
- helper.slider.unbindEvents(); //remove previously bound events
- helper.slider.bindEvents();
-
- helper.slider.selBar.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(1);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.minH.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.maxH.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.fullBar.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(3);
- expect(helper.slider.onMove.callCount).to.equal(2);
-
- helper.slider.ticks.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(4);
- expect(helper.slider.onMove.callCount).to.equal(3);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.onStart = sinon.spy()
+ helper.slider.onMove = sinon.spy()
+ helper.slider.onPointerFocus = sinon.spy()
+
+ helper.slider.unbindEvents() //remove previously bound events
+ helper.slider.bindEvents()
+
+ helper.slider.selBar.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(1)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.minH.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.maxH.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.fullBar.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(3)
+ expect(helper.slider.onMove.callCount).to.equal(2)
+
+ helper.slider.ticks.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(4)
+ expect(helper.slider.onMove.callCount).to.equal(3)
+ })
it('should have a bindEvents that bind correct events for range sliders on desktop', function() {
var sliderConf = {
@@ -546,42 +576,42 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- helper.slider.onStart = sinon.spy();
- helper.slider.onMove = sinon.spy();
- helper.slider.onPointerFocus = sinon.spy();
-
- helper.slider.unbindEvents(); //remove previously bound events
- helper.slider.bindEvents();
-
- helper.slider.selBar.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(1);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.minH.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.maxH.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(3);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.fullBar.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(4);
- expect(helper.slider.onMove.callCount).to.equal(2);
-
- helper.slider.ticks.triggerHandler('mousedown');
- expect(helper.slider.onStart.callCount).to.equal(5);
- expect(helper.slider.onMove.callCount).to.equal(3);
-
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.onPointerFocus.callCount).to.equal(1);
- helper.slider.maxH.triggerHandler('focus');
- expect(helper.slider.onPointerFocus.callCount).to.equal(2);
- });
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ helper.slider.onStart = sinon.spy()
+ helper.slider.onMove = sinon.spy()
+ helper.slider.onPointerFocus = sinon.spy()
+
+ helper.slider.unbindEvents() //remove previously bound events
+ helper.slider.bindEvents()
+
+ helper.slider.selBar.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(1)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.minH.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.maxH.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(3)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.fullBar.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(4)
+ expect(helper.slider.onMove.callCount).to.equal(2)
+
+ helper.slider.ticks.triggerHandler('mousedown')
+ expect(helper.slider.onStart.callCount).to.equal(5)
+ expect(helper.slider.onMove.callCount).to.equal(3)
+
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.onPointerFocus.callCount).to.equal(1)
+ helper.slider.maxH.triggerHandler('focus')
+ expect(helper.slider.onPointerFocus.callCount).to.equal(2)
+ })
it('should have a bindEvents that bind correct events for range sliders on mobile', function() {
var sliderConf = {
@@ -590,37 +620,37 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- helper.slider.onStart = sinon.spy();
- helper.slider.onMove = sinon.spy();
- helper.slider.onPointerFocus = sinon.spy();
-
- helper.slider.unbindEvents(); //remove previously bound events
- helper.slider.bindEvents();
-
- helper.slider.selBar.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(1);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.minH.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(2);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.maxH.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(3);
- expect(helper.slider.onMove.callCount).to.equal(1);
-
- helper.slider.fullBar.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(4);
- expect(helper.slider.onMove.callCount).to.equal(2);
-
- helper.slider.ticks.triggerHandler('touchstart');
- expect(helper.slider.onStart.callCount).to.equal(5);
- expect(helper.slider.onMove.callCount).to.equal(3);
- });
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ helper.slider.onStart = sinon.spy()
+ helper.slider.onMove = sinon.spy()
+ helper.slider.onPointerFocus = sinon.spy()
+
+ helper.slider.unbindEvents() //remove previously bound events
+ helper.slider.bindEvents()
+
+ helper.slider.selBar.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(1)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.minH.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(2)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.maxH.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(3)
+ expect(helper.slider.onMove.callCount).to.equal(1)
+
+ helper.slider.fullBar.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(4)
+ expect(helper.slider.onMove.callCount).to.equal(2)
+
+ helper.slider.ticks.triggerHandler('touchstart')
+ expect(helper.slider.onStart.callCount).to.equal(5)
+ expect(helper.slider.onMove.callCount).to.equal(3)
+ })
it('should have a unbindEvents that unbind all events', function() {
var sliderConf = {
@@ -629,83 +659,90 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- helper.slider.onStart = sinon.spy();
- helper.slider.onMove = sinon.spy();
- helper.slider.onPointerFocus = sinon.spy();
-
- helper.slider.unbindEvents(); //remove previously bound events
- helper.slider.bindEvents();
- helper.slider.unbindEvents();
-
- helper.slider.selBar.triggerHandler('mousedown');
- helper.slider.minH.triggerHandler('mousedown');
- helper.slider.maxH.triggerHandler('mousedown');
- helper.slider.fullBar.triggerHandler('mousedown');
- helper.slider.ticks.triggerHandler('mousedown');
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.onStart.callCount).to.equal(0);
- expect(helper.slider.onMove.callCount).to.equal(0);
- expect(helper.slider.onPointerFocus.callCount).to.equal(0);
- });
- });
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ helper.slider.onStart = sinon.spy()
+ helper.slider.onMove = sinon.spy()
+ helper.slider.onPointerFocus = sinon.spy()
+
+ helper.slider.unbindEvents() //remove previously bound events
+ helper.slider.bindEvents()
+ helper.slider.unbindEvents()
+
+ helper.slider.selBar.triggerHandler('mousedown')
+ helper.slider.minH.triggerHandler('mousedown')
+ helper.slider.maxH.triggerHandler('mousedown')
+ helper.slider.fullBar.triggerHandler('mousedown')
+ helper.slider.ticks.triggerHandler('mousedown')
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.onStart.callCount).to.equal(0)
+ expect(helper.slider.onMove.callCount).to.equal(0)
+ expect(helper.slider.onPointerFocus.callCount).to.equal(0)
+ })
+ })
describe('RTL tests with same config', function() {
- beforeEach(function () {
+ beforeEach(function() {
var sliderConf = {
value: 50,
options: {
floor: 0,
ceil: 100,
step: 10,
- rightToLeft: true
- }
-
- };
- helper.createSlider(sliderConf);
- });
-
- it('should have a valid valueToOffset for positive sliders', function() {
- helper.slider.maxPos = 1000;
- expect(helper.slider.valueToOffset(0)).to.equal(1000);
- expect(helper.slider.valueToOffset(50)).to.equal(500);
- expect(helper.slider.valueToOffset(100)).to.equal(0);
- });
-
- it('should have a valid valueToOffset for negative sliders', function() {
- helper.scope.slider.options.floor = -100;
- helper.scope.slider.options.ceil = 0;
- helper.scope.slider.value = -50;
- helper.scope.$digest();
-
- helper.slider.maxPos = 1000;
- expect(helper.slider.valueToOffset(0)).to.equal(0);
- expect(helper.slider.valueToOffset(-50)).to.equal(500);
- expect(helper.slider.valueToOffset(-100)).to.equal(1000);
- });
-
- it('should have a valid offsetToValue for positive sliders', function() {
- helper.slider.maxPos = 1000;
- expect(helper.slider.offsetToValue(0)).to.equal(100);
- expect(helper.slider.offsetToValue(1000)).to.equal(0);
- expect(helper.slider.offsetToValue(500)).to.equal(50);
- });
-
- it('should have a valid offsetToValue for for negative sliders', function() {
- helper.scope.slider.options.floor = -100;
- helper.scope.slider.options.ceil = 0;
- helper.scope.slider.value = -50;
- helper.scope.$digest();
- helper.slider.maxPos = 1000;
-
- expect(helper.slider.offsetToValue(0)).to.equal(0);
- expect(helper.slider.offsetToValue(1000)).to.equal(-100);
- expect(helper.slider.offsetToValue(500)).to.equal(-50);
- });
- });
- });
-}());
-
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should have a valid valueToPosition for positive sliders', function() {
+ helper.slider.maxPos = 1000
+ expect(helper.slider.valueToPosition(0)).to.equal(1000)
+ expect(helper.slider.valueToPosition(50)).to.equal(500)
+ expect(helper.slider.valueToPosition(100)).to.equal(0)
+ })
+
+ it('should have a valid valueToPosition for negative sliders', function() {
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = 0
+ helper.scope.slider.value = -50
+ helper.scope.$digest()
+
+ helper.slider.maxPos = 1000
+ expect(helper.slider.valueToPosition(0)).to.equal(0)
+ expect(helper.slider.valueToPosition(-50)).to.equal(500)
+ expect(helper.slider.valueToPosition(-100)).to.equal(1000)
+ })
+
+ it('should have a valid positionToValue for positive sliders', function() {
+ helper.slider.maxPos = 1000
+ expect(helper.slider.positionToValue(0)).to.equal(100)
+ expect(helper.slider.positionToValue(1000)).to.equal(0)
+ expect(helper.slider.positionToValue(500)).to.equal(50)
+ })
+
+ it('should have a valid positionToValue for for negative sliders', function() {
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = 0
+ helper.scope.slider.value = -50
+ helper.scope.$digest()
+ helper.slider.maxPos = 1000
+
+ expect(helper.slider.positionToValue(0)).to.equal(0)
+ expect(helper.slider.positionToValue(1000)).to.equal(-100)
+ expect(helper.slider.positionToValue(500)).to.equal(-50)
+ })
+ it('should conditionally call callOnChange in applyModel', function() {
+ sinon.spy(helper.slider, 'callOnChange')
+
+ helper.slider.applyModel(false)
+ helper.slider.callOnChange.called.should.be.false
+
+ helper.slider.applyModel(true)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
+ })
+})()
diff --git a/tests/specs/helper.js b/tests/specs/helper.js
index cb1f9cf..505d058 100644
--- a/tests/specs/helper.js
+++ b/tests/specs/helper.js
@@ -1,135 +1,307 @@
-(function() {
- "use strict";
- var helperModule = angular.module('test-helper', ['rzModule', 'appTemplates']);
+;(function() {
+ 'use strict'
+ var helperModule = angular.module('test-helper', ['rzSlider', 'appTemplates'])
- helperModule.factory('TestHelper', function(RzSlider, RzSliderOptions, $rootScope, $compile, $timeout, $window, $document) {
+ helperModule.factory('TestHelper', function(
+ RzSlider,
+ RzSliderOptions,
+ $rootScope,
+ $compile,
+ $timeout,
+ $window,
+ $document
+ ) {
var h = {
element: null,
scope: null,
- parent: null
- };
+ parent: null,
+ }
h.createSlider = function(sliderObj) {
- var template = '';
- var optionsExpression = sliderObj.optionsExpression || 'slider.options';
+ var template = ''
+ var optionsExpression = sliderObj.optionsExpression || 'slider.options'
if (sliderObj.options || sliderObj.optionsExpression)
- template = '
';
- else
- template = '
';
- h.initSlider(sliderObj, template);
- };
+ template =
+ '
'
+ else template = '
'
+ h.initSlider(sliderObj, template)
+ }
h.createRangeSlider = function(sliderObj) {
- var template = '';
- var optionsExpression = sliderObj.optionsExpression || 'slider.options';
+ var template = ''
+ var optionsExpression = sliderObj.optionsExpression || 'slider.options'
if (sliderObj.options || sliderObj.optionsExpression)
- template = '
';
+ template =
+ '
'
else
- template = '
';
- h.initSlider(sliderObj, template);
- };
+ template =
+ '
'
+ h.initSlider(sliderObj, template)
+ }
h.createRangeSliderWithCustomTemplate = function(sliderObj, templateUrl) {
- var template = '';
- var optionsExpression = sliderObj.optionsExpression || 'slider.options';
+ var template = ''
+ var optionsExpression = sliderObj.optionsExpression || 'slider.options'
if (sliderObj.options || sliderObj.optionsExpression)
- template = '
';
+ ' rz-slider-options="' +
+ optionsExpression +
+ '" rz-slider-tpl-url="' +
+ templateUrl +
+ '">'
else
- template = '
';
- h.initSlider(sliderObj, template);
- };
+ template =
+ '
'
+ h.initSlider(sliderObj, template)
+ }
h.initSlider = function(sliderObj, template) {
- h.scope = $rootScope.$new();
- h.scope.slider = sliderObj;
- h.parent = angular.element('
');
- h.element = $compile(template)(h.scope);
- h.parent.append(h.element);
- angular.element(document).find('body').append(h.parent);
- h.scope.$digest();
- h.slider = h.element.isolateScope().slider;
- };
+ h.scope = $rootScope.$new()
+ h.scope.slider = sliderObj
+ h.parent = angular.element(
+ '
'
+ )
+ h.element = $compile(template)(h.scope)
+ h.parent.append(h.element)
+ angular
+ .element(document)
+ .find('body')
+ .append(h.parent)
+ h.scope.$digest()
+ h.slider = h.element.isolateScope().slider
+ }
h.clean = function() {
//simulate to $destroy event to clean everything
- if (h.scope)
- h.scope.$broadcast('$destroy');
+ if (h.scope) h.scope.$broadcast('$destroy')
//clean the element we append at each test
- if (h.parent)
- h.parent.remove();
- };
-
+ if (h.parent) h.parent.remove()
+ }
h.fireMousedown = function(element, position, vertical) {
- var positionProp = vertical ? 'clientY' : 'clientX';
+ var positionProp = vertical ? 'clientY' : 'clientX'
var event = {
type: 'mousedown',
preventDefault: sinon.stub(),
- stopPropagation: sinon.stub()
- };
- event[positionProp] = position;
+ stopPropagation: sinon.stub(),
+ }
+ event[positionProp] = position
- element.triggerHandler(event);
- return event;
- };
+ element.triggerHandler(event)
+ return event
+ }
h.fireMousemove = function(position, vertical) {
- var positionProp = vertical ? 'clientY' : 'clientX';
+ var positionProp = vertical ? 'clientY' : 'clientX'
var event = {
- type: 'mousemove'
- };
- event[positionProp] = position;
+ type: 'mousemove',
+ }
+ event[positionProp] = position
- $document.triggerHandler(event);
- };
+ $document.triggerHandler(event)
+ }
h.fireMouseup = function() {
var event = {
- type: 'mouseup'
- };
- $document.triggerHandler(event);
- };
+ type: 'mouseup',
+ }
+ $document.triggerHandler(event)
+ }
+
+ h.fireTouchstartWithOriginalEvent = function(
+ element,
+ position,
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = {
+ type: 'touchstart',
+ originalEvent: this.getTouchEvent(
+ 'touchstart',
+ position,
+ vertical,
+ touchIdentifier,
+ touchesIds,
+ sinon.stub()
+ ),
+ }
+
+ element.triggerHandler(event)
+ return event
+ }
+
+ h.fireTouchstartWithoutOriginalEvent = function(
+ element,
+ position,
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = this.getTouchEvent(
+ 'touchstart',
+ position,
+ vertical,
+ touchIdentifier,
+ touchesIds,
+ sinon.stub()
+ )
+
+ element.triggerHandler(event)
+ return event
+ }
+
+ h.fireTouchmoveWithOriginalEvent = function(
+ position,
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = {
+ type: 'touchmove',
+ originalEvent: this.getTouchEvent(
+ 'touchmove',
+ position,
+ vertical,
+ touchIdentifier,
+ touchesIds
+ ),
+ }
+
+ $document.triggerHandler(event)
+ return event
+ }
+
+ h.fireTouchmoveWithoutOriginalEvent = function(
+ position,
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = this.getTouchEvent(
+ 'touchmove',
+ position,
+ vertical,
+ touchIdentifier,
+ touchesIds
+ )
+
+ $document.triggerHandler(event)
+ return event
+ }
+
+ h.fireTouchendWithOriginalEvent = function(
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = {
+ type: 'touchend',
+ originalEvent: this.getTouchEvent(
+ 'touchend',
+ 0,
+ vertical,
+ touchIdentifier,
+ touchesIds
+ ),
+ }
+
+ $document.triggerHandler(event)
+ return event
+ }
+
+ h.fireTouchendWithoutOriginalEvent = function(
+ touchIdentifier,
+ touchesIds,
+ vertical
+ ) {
+ var event = this.getTouchEvent(
+ 'touchend',
+ 0,
+ vertical,
+ touchIdentifier,
+ touchesIds
+ )
+
+ $document.triggerHandler(event)
+ return event
+ }
+
+ h.getTouchEvent = function(
+ type,
+ position,
+ vertical,
+ changedTouchId,
+ touchesIds,
+ preventDefaultAndStopPropagation
+ ) {
+ var positionProp = vertical ? 'clientY' : 'clientX'
+
+ var changedTouches = [{ identifier: changedTouchId }]
+ changedTouches[0][positionProp] = position
+
+ var touches = []
+ for (var i = 0; i < touchesIds.length; i++) {
+ var touch = { identifier: touchesIds[i] }
+ if (touch.identifier == changedTouchId) {
+ touch[positionProp] = position
+ }
+ touches.push(touch)
+ }
+
+ var originalEvent = {
+ type: type,
+ preventDefault: preventDefaultAndStopPropagation,
+ stopPropagation: preventDefaultAndStopPropagation,
+ changedTouches: changedTouches,
+ touches: touches,
+ }
+ return originalEvent
+ }
h.pressKeydown = function(element, key, options) {
- options = options || {};
- key = key.toUpperCase();
+ options = options || {}
+ key = key.toUpperCase()
var event = {
- type: 'keydown'
- };
+ type: 'keydown',
+ }
var keys = {
- 'UP': 38,
- 'DOWN': 40,
- 'LEFT': 37,
- 'RIGHT': 39,
- 'PAGEUP': 33,
- 'PAGEDOWN': 34,
- 'HOME': 36,
- 'END': 35,
- 'SPACE': 32
- };
- var keyCode = keys[key];
- if (options.oldAPI)
- event.which = keyCode;
- else event.keyCode = keyCode;
- element.triggerHandler(event);
- if (options.timeout !== false)
- $timeout.flush();
- };
+ UP: 38,
+ DOWN: 40,
+ LEFT: 37,
+ RIGHT: 39,
+ PAGEUP: 33,
+ PAGEDOWN: 34,
+ HOME: 36,
+ END: 35,
+ SPACE: 32,
+ }
+ var keyCode = keys[key]
+ if (options.oldAPI) event.which = keyCode
+ else event.keyCode = keyCode
+ element.triggerHandler(event)
+ if (options.timeout !== false) $timeout.flush()
+ }
h.getMousePosition = function(value) {
- return h.slider.valueToOffset(value) + h.slider.handleHalfDim + h.slider.sliderElem.rzsp;
- };
+ return (
+ h.slider.valueToPosition(value) +
+ h.slider.handleHalfDim +
+ h.slider.sliderElem.rzsp
+ )
+ }
h.moveMouseToValue = function(value) {
- h.fireMousemove(h.getMousePosition(value));
- };
+ h.fireMousemove(h.getMousePosition(value))
+ }
- return h;
- });
-}());
+ return h
+ })
+})()
diff --git a/tests/specs/keyboard-controls/draggableRangeOnly-range-slider-test.js b/tests/specs/keyboard-controls/draggableRangeOnly-range-slider-test.js
index f973310..a439f06 100644
--- a/tests/specs/keyboard-controls/draggableRangeOnly-range-slider-test.js
+++ b/tests/specs/keyboard-controls/draggableRangeOnly-range-slider-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Keyboard controls - draggableRangeOnly range slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,117 +29,119 @@
options: {
floor: 0,
ceil: 200,
- draggableRangeOnly: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ draggableRangeOnly: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should increment minH/maxH by 1 when RIGHT is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(91);
- expect(helper.scope.slider.max).to.equal(111);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(91)
+ expect(helper.scope.slider.max).to.equal(111)
+ })
it('should increment minH/maxH by 1 when RIGHT is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(91);
- expect(helper.scope.slider.max).to.equal(111);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(91)
+ expect(helper.scope.slider.max).to.equal(111)
+ })
it('should increment minH/maxH by 1 when LEFT is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(89);
- expect(helper.scope.slider.max).to.equal(109);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(89)
+ expect(helper.scope.slider.max).to.equal(109)
+ })
it('should increment minH/maxH by 1 when LEFT is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(89);
- expect(helper.scope.slider.max).to.equal(109);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(89)
+ expect(helper.scope.slider.max).to.equal(109)
+ })
it('should increment minH/maxH by 10% when PAGEUP is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(110);
- expect(helper.scope.slider.max).to.equal(130);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(110)
+ expect(helper.scope.slider.max).to.equal(130)
+ })
it('should increment minH/maxH by 10% when PAGEUP is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(110);
- expect(helper.scope.slider.max).to.equal(130);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(110)
+ expect(helper.scope.slider.max).to.equal(130)
+ })
it('should decrement minH/maxH by 10% when PAGEDOWN is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(70);
- expect(helper.scope.slider.max).to.equal(90);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(70)
+ expect(helper.scope.slider.max).to.equal(90)
+ })
it('should decrement minH/maxH by 10% when PAGEDOWN is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(70);
- expect(helper.scope.slider.max).to.equal(90);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(70)
+ expect(helper.scope.slider.max).to.equal(90)
+ })
it('should set minH to min when HOME is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(20);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(20)
+ })
it('should set minH to min when HOME is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(20);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(20)
+ })
it('should set minH to min when END is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.min).to.equal(180);
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.min).to.equal(180)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should set minH to min when END is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'END');
- expect(helper.scope.slider.min).to.equal(180);
- expect(helper.scope.slider.max).to.equal(200);
- });
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'END')
+ expect(helper.scope.slider.min).to.equal(180)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
+ })
describe('Right to left Keyboard controls - draggableRangeOnly range slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
- beforeEach(inject(function (TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
-
- afterEach(function () {
- helper.clean();
- });
+ afterEach(function() {
+ helper.clean()
+ })
- beforeEach(function () {
+ beforeEach(function() {
var sliderConf = {
min: 90,
max: 110,
@@ -145,95 +149,94 @@
floor: 0,
ceil: 200,
draggableRangeOnly: true,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should decrement minH/maxH by 1 when RIGHT is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(89);
- expect(helper.scope.slider.max).to.equal(109);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(89)
+ expect(helper.scope.slider.max).to.equal(109)
+ })
it('should decrement minH/maxH by 1 when RIGHT is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(89);
- expect(helper.scope.slider.max).to.equal(109);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(89)
+ expect(helper.scope.slider.max).to.equal(109)
+ })
it('should increment minH/maxH by 1 when LEFT is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(91);
- expect(helper.scope.slider.max).to.equal(111);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(91)
+ expect(helper.scope.slider.max).to.equal(111)
+ })
it('should increment minH/maxH by 1 when LEFT is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(91);
- expect(helper.scope.slider.max).to.equal(111);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(91)
+ expect(helper.scope.slider.max).to.equal(111)
+ })
it('should increment minH/maxH by 10% when PAGEUP is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(110);
- expect(helper.scope.slider.max).to.equal(130);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(110)
+ expect(helper.scope.slider.max).to.equal(130)
+ })
it('should increment minH/maxH by 10% when PAGEUP is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(110);
- expect(helper.scope.slider.max).to.equal(130);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(110)
+ expect(helper.scope.slider.max).to.equal(130)
+ })
it('should decrement minH/maxH by 10% when PAGEDOWN is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(70);
- expect(helper.scope.slider.max).to.equal(90);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(70)
+ expect(helper.scope.slider.max).to.equal(90)
+ })
it('should decrement minH/maxH by 10% when PAGEDOWN is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(70);
- expect(helper.scope.slider.max).to.equal(90);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(70)
+ expect(helper.scope.slider.max).to.equal(90)
+ })
it('should set minH to min when HOME is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(20);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(20)
+ })
it('should set minH to min when HOME is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(20);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(20)
+ })
it('should set minH to min when END is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.min).to.equal(180);
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.min).to.equal(180)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should set minH to min when END is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'END');
- expect(helper.scope.slider.min).to.equal(180);
- expect(helper.scope.slider.max).to.equal(200);
- });
- });
-}());
-
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'END')
+ expect(helper.scope.slider.min).to.equal(180)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
+ })
+})()
diff --git a/tests/specs/keyboard-controls/range-slider-test.js b/tests/specs/keyboard-controls/range-slider-test.js
index 1780f7f..4ec4315 100644
--- a/tests/specs/keyboard-controls/range-slider-test.js
+++ b/tests/specs/keyboard-controls/range-slider-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Keyboard controls - range slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -26,266 +28,266 @@
max: 100,
options: {
floor: 0,
- ceil: 200
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ ceil: 200,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should toggle active style when handle focused/blured', function() {
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.false;
- helper.slider.minH.triggerHandler('blur');
- helper.slider.maxH.triggerHandler('focus');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- helper.slider.maxH.triggerHandler('blur');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.false;
- });
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.false
+ helper.slider.minH.triggerHandler('blur')
+ helper.slider.maxH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ helper.slider.maxH.triggerHandler('blur')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.false
+ })
it('should increment minH by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(51);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(51)
+ })
it('should increment maxH by 1 when RIGHT is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(101);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(101)
+ })
it('should decrement minH by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(49);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(49)
+ })
it('should decrement maxH by 1 when LEFT is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(99);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(99)
+ })
it('should increment minH by 10% when PAGEUP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(70);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(70)
+ })
it('should increment maxH by 10% when PAGEUP is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEUP');
- expect(helper.scope.slider.max).to.equal(120);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEUP')
+ expect(helper.scope.slider.max).to.equal(120)
+ })
it('should decrement minH by 10% when PAGEDOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(30);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(30)
+ })
it('should decrement maxH by 10% when PAGEDOWN is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN');
- expect(helper.scope.slider.max).to.equal(80);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN')
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should set minH to min when HOME is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ })
it('should set minH value to previous min and switch min/max when HOME is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ })
it('should set minH value to previous max and switch min/max when END is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.min).to.equal(100);
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.min).to.equal(100)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should set maxH value to max when END is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'END');
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'END')
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should do nothing when SPACE is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'SPACE');
- expect(helper.scope.slider.min).to.equal(50);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.min).to.equal(50)
+ })
it('should do nothing when SPACE is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'SPACE');
- expect(helper.scope.slider.max).to.equal(100);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'SPACE')
+ expect(helper.scope.slider.max).to.equal(100)
+ })
it('should not modify minH when keypress but not focused', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(51);
- helper.slider.minH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.min).to.equal(51);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(51)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.min).to.equal(51)
+ })
it('should not modify maxH when keypress but not focused', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(101);
- helper.slider.maxH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.max).to.equal(101);
- });
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(101)
+ helper.slider.maxH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.max).to.equal(101)
+ })
+ })
describe('Right to left Keyboard controls - range slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function (TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
- afterEach(function () {
- helper.clean();
- });
+ afterEach(function() {
+ helper.clean()
+ })
- beforeEach(function () {
+ beforeEach(function() {
var sliderConf = {
min: 50,
max: 100,
options: {
floor: 0,
ceil: 200,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should decrement minH by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(49);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(49)
+ })
it('should decrement maxH by 1 when RIGHT is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(99);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(99)
+ })
it('should increment minH by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(51);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(51)
+ })
it('should increment maxH by 1 when LEFT is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(101);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(101)
+ })
it('should increment minH by 10% when PAGEUP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.min).to.equal(70);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.min).to.equal(70)
+ })
it('should increment maxH by 10% when PAGEUP is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEUP');
- expect(helper.scope.slider.max).to.equal(120);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEUP')
+ expect(helper.scope.slider.max).to.equal(120)
+ })
it('should decrement minH by 10% when PAGEDOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.min).to.equal(30);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.min).to.equal(30)
+ })
it('should decrement maxH by 10% when PAGEDOWN is pressed', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN');
- expect(helper.scope.slider.max).to.equal(80);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'PAGEDOWN')
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should set minH to min when HOME is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ })
it('should set minH value to previous min and switch min/max when HOME is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'HOME');
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'HOME')
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ })
it('should set minH value to previous max and switch min/max when END is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.min).to.equal(100);
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.min).to.equal(100)
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should set maxH value to max when END is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'END');
- expect(helper.scope.slider.max).to.equal(200);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'END')
+ expect(helper.scope.slider.max).to.equal(200)
+ })
it('should do nothing when SPACE is pressed on minH', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'SPACE');
- expect(helper.scope.slider.min).to.equal(50);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.min).to.equal(50)
+ })
it('should do nothing when SPACE is pressed on maxH', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'SPACE');
- expect(helper.scope.slider.max).to.equal(100);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'SPACE')
+ expect(helper.scope.slider.max).to.equal(100)
+ })
it('should not modify minH when keypress but not focused', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(49);
- helper.slider.minH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.min).to.equal(49);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(49)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.min).to.equal(49)
+ })
it('should not modify maxH when keypress but not focused', function() {
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(99);
- helper.slider.maxH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.max).to.equal(99);
- });
-
- });
-}());
-
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(99)
+ helper.slider.maxH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.max).to.equal(99)
+ })
+ })
+})()
diff --git a/tests/specs/keyboard-controls/single-slider-test.js b/tests/specs/keyboard-controls/single-slider-test.js
index 898fa70..e977f9d 100644
--- a/tests/specs/keyboard-controls/single-slider-test.js
+++ b/tests/specs/keyboard-controls/single-slider-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Keyboard controls - single slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -28,226 +30,482 @@
ceil: 200,
onStart: sinon.spy(),
onChange: sinon.spy(),
- onEnd: sinon.spy()
- }
- };
- helper.createSlider(sliderConf);
- });
+ onEnd: sinon.spy(),
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should call onStart on the first keydown but not after', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- helper.scope.slider.options.onStart.callCount === 1;
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- helper.scope.slider.options.onStart.callCount === 1;
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ helper.scope.slider.options.onStart.callCount === 1
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ helper.scope.slider.options.onStart.callCount === 1
+ })
it('should call onChange on each keydown but after a timeout', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- $timeout.flush();
- helper.scope.slider.options.onChange.callCount === 1;
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- $timeout.flush();
- helper.scope.slider.options.onChange.callCount === 1;
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ $timeout.flush()
+ helper.scope.slider.options.onChange.callCount === 1
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ $timeout.flush()
+ helper.scope.slider.options.onChange.callCount === 1
+ })
it('should call onEnd on keyup and recall onStart if key is down again', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- helper.slider.minH.triggerHandler({type: 'keyup'});
- helper.scope.slider.options.onStart.callCount === 1;
- helper.scope.slider.options.onEnd.callCount === 1;
-
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- helper.slider.minH.triggerHandler({type: 'keyup'});
- helper.scope.slider.options.onStart.callCount === 2;
- helper.scope.slider.options.onEnd.callCount === 2;
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ helper.slider.minH.triggerHandler({ type: 'keyup' })
+ helper.scope.slider.options.onStart.callCount === 1
+ helper.scope.slider.options.onEnd.callCount === 1
+
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ helper.slider.minH.triggerHandler({ type: 'keyup' })
+ helper.scope.slider.options.onStart.callCount === 2
+ helper.scope.slider.options.onEnd.callCount === 2
+ })
it('should toggle active style when handle focused/blured', function() {
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.minH.triggerHandler('blur');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- });
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.minH.triggerHandler('blur')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ })
it('should increment by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should increment by 1 when RIGHT is pressed with oldAPI', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {oldAPI: true});
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { oldAPI: true })
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should decrement by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should increment by 1 when UP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'UP');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should decrement by 1 when DOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'DOWN');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should increment by 10% when PAGEUP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.value).to.equal(120);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(120)
+ })
it('should decrement by 10% when PAGEDOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.value).to.equal(80);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(80)
+ })
it('should set value to min when HOME is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.value).to.equal(0);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
it('should set value to max when END is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.value).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.value).to.equal(200)
+ })
it('should do nothing when SPACE is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'SPACE');
- expect(helper.scope.slider.value).to.equal(100);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.value).to.equal(100)
+ })
it('should not modify when keypress but not focused', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(101);
- helper.slider.minH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.value).to.equal(101);
- });
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(101)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+ })
describe('Right to left Keyboard controls - single slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function (TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
- afterEach(function () {
- helper.clean();
- });
+ afterEach(function() {
+ helper.clean()
+ })
- beforeEach(function () {
+ beforeEach(function() {
var sliderConf = {
value: 100,
options: {
floor: 0,
ceil: 200,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should toggle active style when handle focused/blured', function() {
- helper.slider.minH.triggerHandler('focus');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.minH.triggerHandler('blur');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- });
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.minH.triggerHandler('blur')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ })
it('should decrement by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should decrement by 1 when RIGHT is pressed with oldAPI', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', true);
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', true)
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should increment by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should increment by 1 when UP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'UP');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should decrement by 1 when DOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'DOWN');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should increment by 10% when PAGEUP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.value).to.equal(120);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(120)
+ })
it('should decrement by 10% when PAGEDOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.value).to.equal(80);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(80)
+ })
it('should set value to min when HOME is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'HOME');
- expect(helper.scope.slider.value).to.equal(0);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
it('should set value to max when END is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'END');
- expect(helper.scope.slider.value).to.equal(200);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.value).to.equal(200)
+ })
it('should do nothing when SPACE is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'SPACE');
- expect(helper.scope.slider.value).to.equal(100);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.value).to.equal(100)
+ })
it('should not modify when keypress but not focused', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(99);
- helper.slider.minH.triggerHandler('blur');
- helper.pressKeydown(helper.slider.minH, 'RIGHT', {timeout: false});
- expect(helper.scope.slider.value).to.equal(99);
- });
- });
-}());
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(99)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT', { timeout: false })
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+ })
+
+ describe('Keyboard controls - single slider with reversed controls flag', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ value: 100,
+ options: {
+ floor: 0,
+ ceil: 200,
+ onStart: sinon.spy(),
+ onChange: sinon.spy(),
+ onEnd: sinon.spy(),
+ reversedControls: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should call onStart on the first keydown but not after', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ helper.scope.slider.options.onStart.callCount === 1
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ helper.scope.slider.options.onStart.callCount === 1
+ })
+
+ it('should call onChange on each keydown but after a timeout', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT', { timeout: false })
+ $timeout.flush()
+ helper.scope.slider.options.onChange.callCount === 1
+ helper.pressKeydown(helper.slider.minH, 'LEFT', { timeout: false })
+ $timeout.flush()
+ helper.scope.slider.options.onChange.callCount === 1
+ })
+
+ it('should call onEnd on keyup and recall onStart if key is down again', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ helper.slider.minH.triggerHandler({ type: 'keyup' })
+ helper.scope.slider.options.onStart.callCount === 1
+ helper.scope.slider.options.onEnd.callCount === 1
+
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ helper.slider.minH.triggerHandler({ type: 'keyup' })
+ helper.scope.slider.options.onStart.callCount === 2
+ helper.scope.slider.options.onEnd.callCount === 2
+ })
+
+ it('should toggle active style when handle focused/blured', function() {
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.minH.triggerHandler('blur')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ })
+
+ it('should increment by 1 when RIGHT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+ it('should increment by 1 when LEFT is pressed with oldAPI', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT', { oldAPI: true })
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should decrement by 1 when RIGHT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should increment by 1 when DOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should decrement by 1 when UP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should increment by 10% when PAGEDOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(120)
+ })
+
+ it('should decrement by 10% when PAGEUP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(80)
+ })
+
+ it('should set value to min when END is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
+
+ it('should set value to max when HOME is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.value).to.equal(200)
+ })
+
+ it('should do nothing when SPACE is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.value).to.equal(100)
+ })
+
+ it('should not modify when keypress but not focused', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(101)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'LEFT', { timeout: false })
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+ })
+
+ describe('Right to left Keyboard controls - single slider with reversed controls flag', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ value: 100,
+ options: {
+ floor: 0,
+ ceil: 200,
+ rightToLeft: true,
+ reversedControls: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should toggle active style when handle focused/blured', function() {
+ helper.slider.minH.triggerHandler('focus')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.minH.triggerHandler('blur')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ })
+
+ it('should decrement by 1 when LEFT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should decrement by 1 when LEFT is pressed with oldAPI', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT', true)
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should increment by 1 when RIGHT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should increment by 1 when DOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should decrement by 1 when UP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should increment by 10% when PAGEDOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(120)
+ })
+
+ it('should decrement by 10% when PAGEUP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(80)
+ })
+
+ it('should set value to min when END is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'END')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
+
+ it('should set value to max when HOME is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'HOME')
+ expect(helper.scope.slider.value).to.equal(200)
+ })
+
+ it('should do nothing when SPACE is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'SPACE')
+ expect(helper.scope.slider.value).to.equal(100)
+ })
+
+ it('should not modify when keypress but not focused', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(99)
+ helper.slider.minH.triggerHandler('blur')
+ helper.pressKeydown(helper.slider.minH, 'LEFT', { timeout: false })
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+ })
+})()
diff --git a/tests/specs/keyboard-controls/specific-test.js b/tests/specs/keyboard-controls/specific-test.js
index ada0386..89d87dd 100644
--- a/tests/specs/keyboard-controls/specific-test.js
+++ b/tests/specs/keyboard-controls/specific-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Keyboard controls - specific tests', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
it('should not go below floor', function() {
var sliderConf = {
@@ -26,14 +28,14 @@
options: {
floor: 0,
ceil: 1000,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.value).to.equal(0);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
it('should not go above ceil', function() {
var sliderConf = {
@@ -41,14 +43,14 @@
options: {
floor: 0,
ceil: 1000,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.value).to.equal(1000);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(1000)
+ })
it('should not be modified by keyboard if disabled=true', function() {
var sliderConf = {
@@ -56,14 +58,14 @@
options: {
floor: 0,
ceil: 100,
- disabled: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(10);
- });
+ disabled: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should not be modified by keyboard if readOnly=true', function() {
var sliderConf = {
@@ -71,14 +73,14 @@
options: {
floor: 0,
ceil: 100,
- readOnly: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(10);
- });
+ readOnly: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should not be modified by keyboard if new range is below minRange', function() {
var sliderConf = {
@@ -88,20 +90,20 @@
floor: 0,
ceil: 100,
step: 1,
- minRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
+ minRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH right
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(45);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(45)
//try to move maxH left
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should be modified by keyboard if new range is above minRange', function() {
var sliderConf = {
@@ -111,21 +113,21 @@
floor: 0,
ceil: 100,
step: 1,
- minRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
+ minRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH left
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(44);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(44)
//try to move maxH right
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(56);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(56)
+ })
it('should not be modified by keyboard if new range is above maxRange', function() {
var sliderConf = {
@@ -135,20 +137,20 @@
floor: 0,
ceil: 100,
step: 1,
- maxRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
+ maxRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH left
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(45);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(45)
//try to move maxH right
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should be modified by keyboard if new range is below maxRange', function() {
var sliderConf = {
@@ -158,21 +160,21 @@
floor: 0,
ceil: 100,
step: 1,
- maxRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
+ maxRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH right
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(46);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(46)
//try to move maxH left
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(54);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(54)
+ })
it('should be modified by keyboard if new value is above minLimit', function() {
var sliderConf = {
@@ -181,15 +183,15 @@
floor: 0,
ceil: 100,
step: 1,
- minLimit: 10
- }
- };
- helper.createSlider(sliderConf);
+ minLimit: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
//try to move minH right
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(11);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(11)
+ })
it('should not be modified by keyboard if new value is below minLimit', function() {
var sliderConf = {
@@ -198,15 +200,15 @@
floor: 0,
ceil: 100,
step: 1,
- minLimit: 10
- }
- };
- helper.createSlider(sliderConf);
+ minLimit: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
//try to move minH left
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(10);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should be modified by keyboard if new value is below maxLimit', function() {
var sliderConf = {
@@ -215,15 +217,15 @@
floor: 0,
ceil: 100,
step: 1,
- maxLimit: 90
- }
- };
- helper.createSlider(sliderConf);
+ maxLimit: 90,
+ },
+ }
+ helper.createSlider(sliderConf)
//try to move minH left
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(89);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(89)
+ })
it('should not be modified by keyboard if new value is above maxLimit', function() {
var sliderConf = {
@@ -232,15 +234,15 @@
floor: 0,
ceil: 100,
step: 1,
- maxLimit: 90
- }
- };
- helper.createSlider(sliderConf);
+ maxLimit: 90,
+ },
+ }
+ helper.createSlider(sliderConf)
//try to move minH right
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(90);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(90)
+ })
it('should refocus the slider after a reset if needed and still handle keyboard', function() {
var sliderConf = {
@@ -248,39 +250,41 @@
options: {
floor: 0,
ceil: 100,
- step: 1
- }
- };
- helper.createSlider(sliderConf);
+ step: 1,
+ },
+ }
+ helper.createSlider(sliderConf)
//try to move minH right
- helper.slider.minH.triggerHandler('focus');
+ helper.slider.minH.triggerHandler('focus')
- helper.slider.resetSlider();
+ helper.slider.resetSlider()
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(document.activeElement).to.equal(helper.slider.minH[0]);
- expect(helper.scope.slider.value).to.equal(91);
- });
- });
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(document.activeElement).to.equal(helper.slider.minH[0])
+ expect(helper.scope.slider.value).to.equal(91)
+ })
+ })
describe('Right to left Keyboard controls - specific tests', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
- beforeEach(inject(function (TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
-
- afterEach(function () {
- helper.clean();
- });
+ afterEach(function() {
+ helper.clean()
+ })
it('should not go below floor', function() {
var sliderConf = {
@@ -289,14 +293,14 @@
floor: 0,
ceil: 1000,
step: 10,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEDOWN');
- expect(helper.scope.slider.value).to.equal(0);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEDOWN')
+ expect(helper.scope.slider.value).to.equal(0)
+ })
it('should not go above ceil', function() {
var sliderConf = {
@@ -305,14 +309,14 @@
floor: 0,
ceil: 1000,
step: 10,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'PAGEUP');
- expect(helper.scope.slider.value).to.equal(1000);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'PAGEUP')
+ expect(helper.scope.slider.value).to.equal(1000)
+ })
it('should not be modified by keyboard if disabled=true', function() {
var sliderConf = {
@@ -321,14 +325,14 @@
floor: 0,
ceil: 100,
disabled: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(10);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should not be modified by keyboard if readOnly=true', function() {
var sliderConf = {
@@ -337,14 +341,14 @@
floor: 0,
ceil: 100,
readOnly: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(10);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should not be modified by keyboard if new range is below minRange', function() {
var sliderConf = {
@@ -355,20 +359,20 @@
ceil: 100,
step: 1,
minRange: 10,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH left ( increase in rtl )
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(45);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(45)
//try to move maxH right (decrease in rtl )
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should be modified by keyboard if new range is above minRange', function() {
var sliderConf = {
@@ -379,21 +383,21 @@
ceil: 100,
step: 1,
minRange: 10,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH RIGHT
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(44);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(44)
//try to move maxH LEFT
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(56);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(56)
+ })
it('should not be modified by keyboard if new range is above maxRange', function() {
var sliderConf = {
@@ -404,20 +408,20 @@
ceil: 100,
step: 1,
maxRange: 10,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH right ( increase in rtl )
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.min).to.equal(45);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.min).to.equal(45)
//try to move maxH left (decrease in rtl )
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'LEFT');
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'LEFT')
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should be modified by keyboard if new range is below maxRange', function() {
var sliderConf = {
@@ -428,21 +432,20 @@
ceil: 100,
step: 1,
maxRange: 10,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
//try to move minH LEFT
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.min).to.equal(46);
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.min).to.equal(46)
//try to move maxH RIGHT
- helper.slider.maxH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.maxH, 'RIGHT');
- expect(helper.scope.slider.max).to.equal(54);
- });
- });
-}());
-
+ helper.slider.maxH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.maxH, 'RIGHT')
+ expect(helper.scope.slider.max).to.equal(54)
+ })
+ })
+})()
diff --git a/tests/specs/keyboard-controls/vertical-slider-test.js b/tests/specs/keyboard-controls/vertical-slider-test.js
index 6fe7b84..0a4a0bf 100644
--- a/tests/specs/keyboard-controls/vertical-slider-test.js
+++ b/tests/specs/keyboard-controls/vertical-slider-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Keyboard controls - vertical slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -26,55 +28,116 @@
options: {
floor: 0,
ceil: 200,
- vertical: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ vertical: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should increment by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should increment by 1 when UP is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'UP');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should decrement by 1 when DOWN is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'DOWN');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should decrement by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(99);
- });
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+ })
+
+ describe('Keyboard controls - vertical slider with reverserControls', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
- describe('Right to left Keyboard controls - vertical slider', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ value: 100,
+ options: {
+ floor: 0,
+ ceil: 200,
+ vertical: true,
+ reversedControls: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should increment by 1 when LEFT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
- beforeEach(module('test-helper'));
+ it('should increment by 1 when DOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should decrement by 1 when UP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should decrement by 1 when RIGHT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+ })
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ describe('Right to left Keyboard controls - vertical slider', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -83,37 +146,96 @@
floor: 0,
ceil: 200,
vertical: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should decrement by 1 when RIGHT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'RIGHT');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should decrement by 1 when UP is pressed', function() {
//while not strictly left to right this does allow also reversing vertical bars
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'UP');
- expect(helper.scope.slider.value).to.equal(99);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
it('should increment by 1 when DOWN is pressed', function() {
//while not strictly left to right this does allow also reversing vertical bars
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'DOWN');
- expect(helper.scope.slider.value).to.equal(101);
- });
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
it('should increment by 1 when LEFT is pressed', function() {
- helper.slider.minH.triggerHandler('focus');
- helper.pressKeydown(helper.slider.minH, 'LEFT');
- expect(helper.scope.slider.value).to.equal(101);
- });
- });
-}());
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+ })
+
+ describe('Right to left Keyboard controls - vertical slider', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ value: 100,
+ options: {
+ floor: 0,
+ ceil: 200,
+ vertical: true,
+ rightToLeft: true,
+ reversedControls: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should decrement by 1 when LEFT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'LEFT')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+ it('should decrement by 1 when DOWN is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'DOWN')
+ expect(helper.scope.slider.value).to.equal(99)
+ })
+
+ it('should increment by 1 when UP is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'UP')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+
+ it('should increment by 1 when RIGHT is pressed', function() {
+ helper.slider.minH.triggerHandler('focus')
+ helper.pressKeydown(helper.slider.minH, 'RIGHT')
+ expect(helper.scope.slider.value).to.equal(101)
+ })
+ })
+})()
diff --git a/tests/specs/labels-test.js b/tests/specs/labels-test.js
index 241d7a3..30c3dcc 100644
--- a/tests/specs/labels-test.js
+++ b/tests/specs/labels-test.js
@@ -1,63 +1,65 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Single slider initialisation - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
it('should display floor and ceil labels when handle is at the middle', function() {
var sliderConf = {
value: 50,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ ceil: 100,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should hide floor and display ceil labels when handle is at min', function() {
var sliderConf = {
value: 0,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ ceil: 100,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should show floor and hide ceil labels when handle is at max', function() {
var sliderConf = {
value: 100,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
+ ceil: 100,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
it('should display floor and ceil labels when handle is at the middle for RTL slider', function() {
var sliderConf = {
@@ -65,13 +67,13 @@
options: {
floor: 0,
ceil: 100,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should hide floor and display ceil labels when handle is at min for RTL slider', function() {
var sliderConf = {
@@ -79,13 +81,13 @@
options: {
floor: 0,
ceil: 100,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should show floor and hide ceil labels when handle is at max for RTL slider', function() {
var sliderConf = {
@@ -93,13 +95,13 @@
options: {
floor: 0,
ceil: 100,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
it('should hide floor and ceil labels when minHandle is at min and maxHandle at max for range slider', function() {
var sliderConf = {
@@ -107,13 +109,13 @@
max: 100,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
+ ceil: 100,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
it('should hide floor and ceil labels when minHandle is at min and maxHandle at max for range RTL slider', function() {
var sliderConf = {
@@ -122,13 +124,13 @@
options: {
floor: 0,
ceil: 100,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
it('should hide floor and ceil labels when cmb label is overlapping, for range slider', function() {
var sliderConf = {
@@ -137,17 +139,17 @@
options: {
floor: 0,
ceil: 100,
- translate: function(v, _, which){
- if(which != 'model' && which != 'high') return v;
+ translate: function(v, _, which) {
+ if (which != 'model' && which != 'high') return v
return "I'm whatever long text ==============================================================================================================================================================="
- }
- }
- };
+ },
+ },
+ }
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
it('should hide floor and ceil labels when cmb label is overlapping, for range RTL slider', function() {
var sliderConf = {
@@ -156,19 +158,16 @@
options: {
floor: 0,
ceil: 100,
- translate: function(v, _, which){
- if(which != 'model' && which != 'high') return v;
+ translate: function(v, _, which) {
+ if (which != 'model' && which != 'high') return v
return "I'm whatever long text ==============================================================================================================================================================="
- }
+ },
},
- rightToLeft: true
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('hidden');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden');
- });
-
-
- });
-}());
-
+ rightToLeft: true,
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('hidden')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('hidden')
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/draggable-range-slider-horizontal-test.js b/tests/specs/mouse-controls/draggable-range-slider-horizontal-test.js
index 6747417..ae7630d 100644
--- a/tests/specs/mouse-controls/draggable-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/draggable-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - draggableRange Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,217 +29,224 @@
options: {
floor: 0,
ceil: 100,
- draggableRange: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ draggableRange: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- var event = helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- var event = helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move whole range when moved within slider range', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
- helper.fireMousedown(helper.slider.selBar, 0);
+ helper.fireMousedown(helper.slider.selBar, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
-
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(2)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
it('should handle click on selbar and move move range when near 0 and moved left', function() {
- helper.scope.slider.min = 10;
- helper.scope.$digest();
+ helper.scope.slider.min = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
- helper.scope.slider.min = 0;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at 0 and moved left", function() {
+ helper.scope.slider.min = 0
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-100);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-100)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should handle click on selbar and move move range when near max and moved right', function() {
- helper.scope.slider.max = 90;
- helper.scope.$digest();
+ helper.scope.slider.max = 90
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
- helper.scope.slider.max = 100;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at max and moved right", function() {
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should a working positionTrackingBar', function() {
var newMin = 50,
newMax = 90,
- minOffset = helper.slider.valueToOffset(newMin),
- maxOffset = helper.slider.valueToOffset(newMax);
- helper.slider.positionTrackingBar(newMin, newMax, minOffset, maxOffset);
-
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(90);
- expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
- expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
- });
+ minposition = Math.round(helper.slider.valueToPosition(newMin)),
+ maxposition = Math.round(helper.slider.valueToPosition(newMax))
+ helper.slider.positionTrackingBar(
+ newMin,
+ newMax,
+ minposition,
+ maxposition
+ )
+
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(90)
+ expect(helper.slider.minH.css('left')).to.equal(minposition + 'px')
+ expect(helper.slider.maxH.css('left')).to.equal(maxposition + 'px')
+ })
it('should respect minLimit option', function() {
- helper.scope.slider.options.minLimit = 20;
- helper.scope.$digest();
+ helper.scope.slider.options.minLimit = 20
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should respect maxLimit option', function() {
- helper.scope.slider.options.maxLimit = 80;
- helper.scope.$digest();
+ helper.scope.slider.options.maxLimit = 80
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- });
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
+ })
describe('Right to left Mouse controls - draggableRange Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -247,179 +256,184 @@
floor: 0,
ceil: 100,
draggableRange: true,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
var expectedValue = 50,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
var expectedValue = 50,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
var expectedValue = 80,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
var expectedValue = 20,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move whole range when moved within slider range', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
- helper.fireMousedown(helper.slider.selBar, 0);
+ helper.fireMousedown(helper.slider.selBar, 0)
var moveValue = 10,
- offset = helper.slider.maxPos - helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
-
- expect(helper.scope.slider.min).to.equal(30);
- expect(helper.scope.slider.max).to.equal(50);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position =
+ helper.slider.maxPos - helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+
+ expect(helper.scope.slider.min).to.equal(30)
+ expect(helper.scope.slider.max).to.equal(50)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(2)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
it('should handle click on selbar and move move range when near 0 and moved right', function() {
- helper.scope.slider.min = 10;
- helper.scope.$digest();
+ helper.scope.slider.min = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(1000)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- expect(helper.slider.tracking).to.equal('highValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ expect(helper.slider.tracking).to.equal('highValue')
+ })
- it('should handle click on selbar and don\'t move range when already at 0 and moved right', function() {
- helper.scope.slider.min = 0;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at 0 and moved right", function() {
+ helper.scope.slider.min = 0
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(100);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(100)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('highValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('highValue')
+ })
it('should handle click on selbar and move range when near max and moved left', function() {
- helper.scope.slider.max = 90;
- helper.scope.$digest();
+ helper.scope.slider.max = 90
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('highValue');
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('highValue')
+ })
- it('should handle click on selbar and don\'t move range when already at max and moved left', function() {
- helper.scope.slider.max = 100;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at max and moved left", function() {
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('highValue');
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('highValue')
+ })
it('should a working positionTrackingBar', function() {
var newMin = 50,
- newMax = 90,
- minOffset = helper.slider.valueToOffset(newMin),
- maxOffset = helper.slider.valueToOffset(newMax);
- helper.slider.positionTrackingBar(newMin, newMax, minOffset, maxOffset);
-
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(90);
- expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
- expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
- });
- });
-}());
-
+ newMax = 90,
+ minposition = Math.round(helper.slider.valueToPosition(newMin)),
+ maxposition = Math.round(helper.slider.valueToPosition(newMax))
+ helper.slider.positionTrackingBar(
+ newMin,
+ newMax,
+ minposition,
+ maxposition
+ )
+
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(90)
+ expect(helper.slider.minH.css('left')).to.equal(minposition + 'px')
+ expect(helper.slider.maxH.css('left')).to.equal(maxposition + 'px')
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/draggableOnly-range-slider-horizontal-test.js b/tests/specs/mouse-controls/draggableOnly-range-slider-horizontal-test.js
index 846827a..70d78b3 100644
--- a/tests/specs/mouse-controls/draggableOnly-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/draggableOnly-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - draggableRangeOnly Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,161 +29,163 @@
options: {
floor: 0,
ceil: 100,
- draggableRangeOnly: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ draggableRangeOnly: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnChange')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should not handle click on fullbar', function() {
- sinon.spy(helper.slider, 'callOnStart');
+ sinon.spy(helper.slider, 'callOnStart')
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
+ position = helper.slider.valueToPosition(moveValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('');
- helper.slider.callOnStart.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('')
+ helper.slider.callOnStart.called.should.be.false
+ })
it('should handle click on selbar and move whole range when moved within slider range', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
- helper.fireMousedown(helper.slider.selBar, 0);
+ helper.fireMousedown(helper.slider.selBar, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
-
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(2)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
it('should handle click on selbar and move range when near 0 and moved left', function() {
- helper.scope.slider.min = 10;
- helper.scope.$digest();
+ helper.scope.slider.min = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
- helper.scope.slider.min = 0;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at 0 and moved left", function() {
+ helper.scope.slider.min = 0
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-100);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-100)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should handle click on selbar and move range when near max and moved right', function() {
- helper.scope.slider.max = 90;
- helper.scope.$digest();
+ helper.scope.slider.max = 90
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
- helper.scope.slider.max = 100;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at max and moved right", function() {
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
- helper.scope.slider.min = 1050;
- helper.scope.slider.max = 1550;
- helper.scope.slider.options.floor = 1000;
- helper.scope.slider.options.ceil = 5000;
- helper.scope.$digest();
+ helper.scope.slider.min = 1050
+ helper.scope.slider.max = 1550
+ helper.scope.slider.options.floor = 1000
+ helper.scope.slider.options.ceil = 5000
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(1000);
- expect(helper.scope.slider.max).to.equal(1500);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
- });
+ expect(helper.scope.slider.min).to.equal(1000)
+ expect(helper.scope.slider.max).to.equal(1500)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
+ })
describe('Right to left Mouse controls - draggableRangeOnly Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -191,141 +195,140 @@
floor: 0,
ceil: 100,
draggableRangeOnly: true,
- leftToRight: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ leftToRight: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnChange')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should not handle click on fullbar', function() {
- sinon.spy(helper.slider, 'callOnStart');
+ sinon.spy(helper.slider, 'callOnStart')
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
+ position = helper.slider.valueToPosition(moveValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('');
- helper.slider.callOnStart.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('')
+ helper.slider.callOnStart.called.should.be.false
+ })
it('should handle click on selbar and move whole range when moved within slider range', function() {
- sinon.spy(helper.slider, 'positionTrackingBar');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingBar')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
- helper.fireMousedown(helper.slider.selBar, 0);
+ helper.fireMousedown(helper.slider.selBar, 0)
var moveValue = 10,
- offset = helper.slider.valueToOffset(moveValue);
- helper.fireMousemove(offset);
-
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingBar.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position = helper.slider.valueToPosition(moveValue)
+ helper.fireMousemove(position)
+
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingBar.callCount).to.equal(2)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
it('should handle click on selbar and move range when near 0 and moved left', function() {
- helper.scope.slider.min = 10;
- helper.scope.$digest();
+ helper.scope.slider.min = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(50);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(50)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
- helper.scope.slider.min = 0;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at 0 and moved left", function() {
+ helper.scope.slider.min = 0
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-100);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-100)
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(60);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(60)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should handle click on selbar and move range when near max and moved right', function() {
- helper.scope.slider.max = 90;
- helper.scope.$digest();
+ helper.scope.slider.max = 90
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
- it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
- helper.scope.slider.max = 100;
- helper.scope.$digest();
+ it("should handle click on selbar and don't move range when already at max and moved right", function() {
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(helper.slider.maxPos);
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(helper.slider.maxPos)
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(100);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(100)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
- helper.scope.slider.min = 1050;
- helper.scope.slider.max = 1550;
- helper.scope.slider.options.floor = 1000;
- helper.scope.slider.options.ceil = 5000;
- helper.scope.$digest();
-
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousemove(-1000);
-
- expect(helper.scope.slider.min).to.equal(1000);
- expect(helper.scope.slider.max).to.equal(1500);
- expect(helper.slider.tracking).to.equal('lowValue');
- });
- });
-}());
-
+ helper.scope.slider.min = 1050
+ helper.scope.slider.max = 1550
+ helper.scope.slider.options.floor = 1000
+ helper.scope.slider.options.ceil = 5000
+ helper.scope.$digest()
+
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousemove(-1000)
+
+ expect(helper.scope.slider.min).to.equal(1000)
+ expect(helper.scope.slider.max).to.equal(1500)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/minMaxLimit-range-slider-horizontal-test.js b/tests/specs/mouse-controls/minMaxLimit-range-slider-horizontal-test.js
index 091ca65..6376be2 100644
--- a/tests/specs/mouse-controls/minMaxLimit-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/minMaxLimit-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - minLimit!=null && maxLimit!=null Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -28,63 +30,65 @@
floor: 0,
ceil: 100,
minLimit: 40,
- maxLimit: 60
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ maxLimit: 60,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should be able to modify minH above minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 42;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(42);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 42
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(42)
+ })
it('should not be able to modify minH below minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(40)
+ })
it('should be able to modify maxH below maxLimit', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 58;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(58);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 58
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(58)
+ })
it('should not be able to modify maxH above maxLimit', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(60);
- });
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(60)
+ })
+ })
describe('Right to left Mouse controls - minLimit!=null && maxLimit!=null Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -95,43 +99,42 @@
ceil: 100,
minLimit: 40,
maxLimit: 60,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should be able to modify minH above minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 42;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(42);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 42
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(42)
+ })
it('should not be able to modify minH below minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(40)
+ })
it('should be able to modify maxH below maxLimit', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 58;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(58);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 58
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(58)
+ })
it('should not be able to modify maxH above maxLimit', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(60);
- });
- });
-}());
-
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(60)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/minMaxLimit-single-slider-horizontal-test.js b/tests/specs/mouse-controls/minMaxLimit-single-slider-horizontal-test.js
index 5e99aa2..f5654a6 100644
--- a/tests/specs/mouse-controls/minMaxLimit-single-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/minMaxLimit-single-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - minLimit!=null && maxLimit!=null Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,63 +29,65 @@
floor: 0,
ceil: 100,
minLimit: 40,
- maxLimit: 60
- }
- };
- helper.createSlider(sliderConf);
- });
+ maxLimit: 60,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should be able to modify minH above minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 42;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(42);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 42
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(42)
+ })
it('should not be able to modify minH below minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(40)
+ })
it('should be able to modify minH below maxLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 58;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(58);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 58
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(58)
+ })
it('should not be able to modify minH above maxLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(60);
- });
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(60)
+ })
+ })
describe('Right to left Mouse controls - minLimit!=null && maxLimit!=null Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -93,43 +97,42 @@
ceil: 100,
minLimit: 40,
maxLimit: 60,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should be able to modify minH above minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 42;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(42);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 42
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(42)
+ })
it('should not be able to modify minH below minLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(40)
+ })
it('should be able to modify minH below maxLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 58;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(58);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 58
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(58)
+ })
it('should not be able to modify minH above maxLimit', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(60);
- });
- });
-}());
-
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(60)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/minMaxRange-noSwitching-range-slider-horizontal-test.js b/tests/specs/mouse-controls/minMaxRange-noSwitching-range-slider-horizontal-test.js
index db7cd5f..5f8184b 100644
--- a/tests/specs/mouse-controls/minMaxRange-noSwitching-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/minMaxRange-noSwitching-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - minRange and noSwitching Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -29,117 +31,119 @@
ceil: 100,
minRange: 10,
maxRange: 50,
- noSwitching: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ noSwitching: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ })
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should modify the min value if new range is larger than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ })
it('should modify the max value if new range is larger than than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should not switch min/max when moving minH even if the range is large enough', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should not switch min/max when moving maxH even if the range is large enough', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should not modify any value if new range would be larger than maxRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 0;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(5);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 0
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(5)
+ })
it('should not modify any value if new range would be larger than maxRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 100;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(95);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 100
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(95)
+ })
it('should not switch min/max when moving minH far higher than maxH (issue #377)', function() {
- helper.scope.slider.min = 0;
- helper.scope.slider.max = 10;
- helper.scope.$digest();
+ helper.scope.slider.min = 0
+ helper.scope.slider.max = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 100;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(10);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 100
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(10)
+ })
it('should not switch min/max when moving maxH far lower than minH (issue #377)', function() {
- helper.scope.slider.min = 90;
- helper.scope.slider.max = 100;
- helper.scope.$digest();
-
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 0;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(90);
- expect(helper.scope.slider.max).to.equal(100);
- });
- });
+ helper.scope.slider.min = 90
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
+
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 0
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(90)
+ expect(helper.scope.slider.max).to.equal(100)
+ })
+ })
describe('Right to left Mouse controls - minRange and noSwitching Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -150,63 +154,61 @@
ceil: 100,
minRange: 10,
noSwitching: true,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
+ helper.fireMousedown(helper.slider.minH, 0)
var expectedValue = 50,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(-offset);
- expect(helper.scope.slider.min).to.equal(45);
- });
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(-position)
+ expect(helper.scope.slider.min).to.equal(45)
+ })
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
+ helper.fireMousedown(helper.slider.maxH, 0)
var expectedValue = 50,
- offset = helper.slider.maxPos - helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ position = helper.slider.maxPos - helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should modify the min value if new range is larger than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ })
it('should modify the max value if new range is larger than than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should not switch min/max when moving minH even if the range is large enough', function() {
- helper.fireMousedown(helper.slider.minH, 0);
+ helper.fireMousedown(helper.slider.minH, 0)
var expectedValue = 80,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(-offset);
- expect(helper.scope.slider.min).to.equal(45);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(-position)
+ expect(helper.scope.slider.min).to.equal(45)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should not switch min/max when moving maxH even if the range is large enough', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- expect(helper.scope.slider.max).to.equal(55);
- });
- });
-
-}());
-
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/minMaxRange-range-slider-horizontal-test.js b/tests/specs/mouse-controls/minMaxRange-range-slider-horizontal-test.js
index b318ffe..88789ed 100644
--- a/tests/specs/mouse-controls/minMaxRange-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/minMaxRange-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - minRange!=0 Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,79 +29,81 @@
options: {
floor: 0,
ceil: 100,
- minRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ minRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ })
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should modify the min value if new range is larger than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ })
it('should modify the max value if new range is larger than than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should modify the min value if switch min/max with a value large enough', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(55);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(55)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should modify the max value if switch min/max with a value large enough', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.scope.slider.max).to.equal(45);
- });
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.scope.slider.max).to.equal(45)
+ })
+ })
describe('Mouse controls - maxRange!=0 Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -108,63 +112,65 @@
options: {
floor: 0,
ceil: 100,
- maxRange: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ maxRange: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not modify any value if new range would be larger than maxRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ })
it('should not modify any value if new range would be larger than maxRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should modify the min value if new range is smaller than maxRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ })
it('should modify the max value if new range is smaller than than maxRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
+ })
describe('Right to left Mouse controls - minRange!=0 Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -174,60 +180,58 @@
floor: 0,
ceil: 100,
minRange: 10,
- rightToLeft: true
- }
-
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(45)
+ })
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(55)
+ })
it('should modify the min value if new range is larger than minRange when moving minH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 30;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 30
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ })
it('should modify the max value if new range is larger than than minRange when moving maxH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 70;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 70
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should modify the min value if switch min/max with a value large enough', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(55);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(55)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ })
it('should modify the max value if switch min/max with a value large enough', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.scope.slider.max).to.equal(45);
- });
- });
-}());
-
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.scope.slider.max).to.equal(45)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/noSwitching-range-slider-horizontal-test.js b/tests/specs/mouse-controls/noSwitching-range-slider-horizontal-test.js
index 76c7f58..528f260 100644
--- a/tests/specs/mouse-controls/noSwitching-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/noSwitching-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - noSwitching Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,75 +29,77 @@
options: {
floor: 0,
ceil: 100,
- noSwitching: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ noSwitching: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not switch min and max handles if minH is dragged after maxH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 60;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 60
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(55)
+ })
it('should not switch min and max handles if maxH is dragged before minH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(45)
+ })
it('should move minH if minH==maxH and click is on the left side of the bar', function() {
- helper.scope.slider.min = helper.scope.slider.max = 50;
- helper.scope.$digest();
+ helper.scope.slider.min = helper.scope.slider.max = 50
+ helper.scope.$digest()
var expectedValue = 30,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- helper.fireMousedown(helper.slider.fullBar, offset);
+ helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(30);
- expect(helper.scope.slider.max).to.equal(50);
- });
+ expect(helper.scope.slider.min).to.equal(30)
+ expect(helper.scope.slider.max).to.equal(50)
+ })
it('should move maxH if minH==maxH and click is on the right side of the bar', function() {
- helper.scope.slider.min = helper.scope.slider.max = 50;
- helper.scope.$digest();
+ helper.scope.slider.min = helper.scope.slider.max = 50
+ helper.scope.$digest()
var expectedValue = 70,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- helper.fireMousedown(helper.slider.fullBar, offset);
+ helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- });
- });
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ })
+ })
describe('Right to left Mouse controls - noSwitching Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -105,55 +109,54 @@
floor: 0,
ceil: 100,
noSwitching: true,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should not switch min and max handles if minH is dragged after maxH', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 60;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(55);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 60
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(55)
+ })
it('should not switch min and max handles if maxH is dragged before minH', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(45);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(45)
+ })
it('should move minH if minH==maxH and click is on the left side of the bar', function() {
- helper.scope.slider.min = helper.scope.slider.max = 50;
- helper.scope.$digest();
+ helper.scope.slider.min = helper.scope.slider.max = 50
+ helper.scope.$digest()
var expectedValue = 30,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- helper.fireMousedown(helper.slider.fullBar, offset);
+ helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(30);
- expect(helper.scope.slider.max).to.equal(50);
- });
+ expect(helper.scope.slider.min).to.equal(30)
+ expect(helper.scope.slider.max).to.equal(50)
+ })
it('should move maxH if minH==maxH and click is on the right side of the bar', function() {
- helper.scope.slider.min = helper.scope.slider.max = 50;
- helper.scope.$digest();
+ helper.scope.slider.min = helper.scope.slider.max = 50
+ helper.scope.$digest()
var expectedValue = 70,
- offset = helper.getMousePosition(expectedValue);
-
- helper.fireMousedown(helper.slider.fullBar, offset);
+ position = helper.getMousePosition(expectedValue)
- expect(helper.scope.slider.min).to.equal(50);
- expect(helper.scope.slider.max).to.equal(70);
- });
- });
-}());
+ helper.fireMousedown(helper.slider.fullBar, position)
+ expect(helper.scope.slider.min).to.equal(50)
+ expect(helper.scope.slider.max).to.equal(70)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/onlyBindHandles-single-slider-horizontal-test.js b/tests/specs/mouse-controls/onlyBindHandles-single-slider-horizontal-test.js
index 7b6fdc8..1db382a 100644
--- a/tests/specs/mouse-controls/onlyBindHandles-single-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/onlyBindHandles-single-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - onlyBindHandles Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,59 +29,61 @@
floor: 0,
ceil: 100,
showTicks: true,
- onlyBindHandles: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ onlyBindHandles: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should do nothing when a click happen on another element than the handle', function() {
- helper.scope.slider.value = 100;
- helper.scope.$digest();
+ helper.scope.slider.value = 100
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'positionTrackingHandle');
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousedown(helper.slider.fullBar, 0);
- helper.fireMousedown(helper.slider.ticks, 0);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousedown(helper.slider.fullBar, 0)
+ helper.fireMousedown(helper.slider.ticks, 0)
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.false;
- });
- });
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.false
+ })
+ })
describe('Right to left Mouse controls - onlyBindHandles Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -89,39 +93,38 @@
ceil: 100,
showTicks: true,
onlyBindHandles: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should do nothing when a click happen on another element than the handle', function() {
- helper.scope.slider.value = 100;
- helper.scope.$digest();
-
- sinon.spy(helper.slider, 'positionTrackingHandle');
- helper.fireMousedown(helper.slider.selBar, 0);
- helper.fireMousedown(helper.slider.fullBar, 0);
- helper.fireMousedown(helper.slider.ticks, 0);
-
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.false;
- });
- });
-}());
-
+ helper.scope.slider.value = 100
+ helper.scope.$digest()
+
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ helper.fireMousedown(helper.slider.selBar, 0)
+ helper.fireMousedown(helper.slider.fullBar, 0)
+ helper.fireMousedown(helper.slider.ticks, 0)
+
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.false
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/pushRange-range-slider-horizontal-test.js b/tests/specs/mouse-controls/pushRange-range-slider-horizontal-test.js
index 3de2012..d182637 100644
--- a/tests/specs/mouse-controls/pushRange-range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/pushRange-range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - pushRange Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,108 +29,126 @@
options: {
floor: 0,
ceil: 100,
- pushRange: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ pushRange: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should push maxH when moving minH above it', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- helper.moveMouseToValue(60);
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(61);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(60)
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(61)
+ })
it('should push minH when moving maxH below it', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- helper.moveMouseToValue(40);
- expect(helper.scope.slider.min).to.equal(39);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(40)
+ expect(helper.scope.slider.min).to.equal(39)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should not move maxH above ceil when moving minH to ceil', function() {
- helper.fireMousedown(helper.slider.minH, 0);
- helper.moveMouseToValue(100);
- expect(helper.scope.slider.min).to.equal(99);
- expect(helper.scope.slider.max).to.equal(100);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(100)
+ expect(helper.scope.slider.min).to.equal(99)
+ expect(helper.scope.slider.max).to.equal(100)
+ })
it('should not move minH below floor when moving maxH to floor', function() {
- helper.fireMousedown(helper.slider.maxH, 0);
- helper.moveMouseToValue(0);
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(1);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(0)
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(1)
+ })
it('should push maxH according to step', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.$digest();
+ helper.scope.slider.options.step = 5
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.minH, 0);
- helper.moveMouseToValue(60);
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(65);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(60)
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(65)
+ })
it('should push minH according to step', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.$digest();
+ helper.scope.slider.options.step = 5
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.maxH, 0);
- helper.moveMouseToValue(40);
- expect(helper.scope.slider.min).to.equal(35);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(40)
+ expect(helper.scope.slider.min).to.equal(35)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should push maxH according to minRange when both step and minRange are defined', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.slider.options.minRange = 10;
- helper.scope.$digest();
+ helper.scope.slider.options.step = 5
+ helper.scope.slider.options.minRange = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.minH, 0);
- helper.moveMouseToValue(60);
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(70);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(60)
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(70)
+ })
it('should push minH according to minRange when both step and minRange are defined', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.slider.options.minRange = 10;
- helper.scope.$digest();
+ helper.scope.slider.options.step = 5
+ helper.scope.slider.options.minRange = 10
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.maxH, 0);
- helper.moveMouseToValue(40);
- expect(helper.scope.slider.min).to.equal(30);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(40)
+ expect(helper.scope.slider.min).to.equal(30)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should push maxH according to minRange when minRange is 0', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.slider.options.minRange = 0;
- helper.scope.$digest();
+ helper.scope.slider.options.step = 5
+ helper.scope.slider.options.minRange = 0
+ helper.scope.$digest()
- helper.fireMousedown(helper.slider.minH, 0);
- helper.moveMouseToValue(60);
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(60);
- });
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(60)
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(60)
+ })
it('should push minH according to minRange when minRange is 0', function() {
- helper.scope.slider.options.step = 5;
- helper.scope.slider.options.minRange = 0;
- helper.scope.$digest();
-
- helper.fireMousedown(helper.slider.maxH, 0);
- helper.moveMouseToValue(40);
- expect(helper.scope.slider.min).to.equal(40);
- expect(helper.scope.slider.max).to.equal(40);
- });
- });
-
-}());
-
+ helper.scope.slider.options.step = 5
+ helper.scope.slider.options.minRange = 0
+ helper.scope.$digest()
+
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(40)
+ expect(helper.scope.slider.min).to.equal(40)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
+
+ it('should pull minH when moving maxH above maxRange', function() {
+ helper.scope.slider.options.maxRange = 15
+ helper.scope.$digest()
+
+ helper.fireMousedown(helper.slider.maxH, 0)
+ helper.moveMouseToValue(80)
+ expect(helper.scope.slider.min).to.equal(65)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
+
+ it('should pull maxH when moving minH above maxRange', function() {
+ helper.scope.slider.options.maxRange = 15
+ helper.scope.$digest()
+
+ helper.fireMousedown(helper.slider.minH, 0)
+ helper.moveMouseToValue(20)
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(35)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/range-slider-horizontal-test.js b/tests/specs/mouse-controls/range-slider-horizontal-test.js
index e5918b4..bf8a05e 100644
--- a/tests/specs/mouse-controls/range-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/range-slider-horizontal-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -26,265 +28,267 @@
max: 100,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ ceil: 100,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ })
it('should handle click and drag on minH and switch min/max if needed when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- helper.slider.focusElement.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ helper.slider.focusElement.called.should.be.false
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ })
it('should handle click and drag on maxH and switch min/max if needed when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- helper.slider.focusElement.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ helper.slider.focusElement.called.should.be.false
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.selBar, offset);
+ var event = helper.fireMousedown(helper.slider.selBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.selBar, offset);
+ var event = helper.fireMousedown(helper.slider.selBar, position)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
describe('Right to left Mouse controls - Range Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -293,245 +297,244 @@
options: {
floor: 0,
ceil: 100,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ var event = helper.fireMousedown(helper.slider.minH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0);
+ var event = helper.fireMousedown(helper.slider.maxH, 0)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 50;
- helper.moveMouseToValue(expectedValue);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 50
+ helper.moveMouseToValue(expectedValue)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ })
it('should handle click and drag on minH and switch min/max if needed when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 80;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 80
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- helper.slider.focusElement.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ helper.slider.focusElement.called.should.be.false
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ })
it('should handle click and drag on maxH and switch min/max if needed when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'focusElement');
- helper.fireMousedown(helper.slider.maxH, 0);
- var expectedValue = 20;
- helper.moveMouseToValue(expectedValue);
+ sinon.spy(helper.slider, 'focusElement')
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var expectedValue = 20
+ helper.moveMouseToValue(expectedValue)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- helper.slider.focusElement.called.should.be.false;
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ helper.slider.focusElement.called.should.be.false
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.fullBar, offset);
+ var event = helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.selBar, offset);
+ var event = helper.fireMousedown(helper.slider.selBar, position)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.getMousePosition(expectedValue);
-
- var event = helper.fireMousedown(helper.slider.selBar, offset);
-
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
-}());
-
+ position = helper.getMousePosition(expectedValue)
+
+ var event = helper.fireMousedown(helper.slider.selBar, position)
+
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/range-slider-vertical-test.js b/tests/specs/mouse-controls/range-slider-vertical-test.js
index 2560662..b22f9ed 100644
--- a/tests/specs/mouse-controls/range-slider-vertical-test.js
+++ b/tests/specs/mouse-controls/range-slider-vertical-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - Range Vertical', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,233 +29,259 @@
options: {
floor: 0,
ceil: 100,
- vertical: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ vertical: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 80,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
var expectedValue = 20,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.selBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.selBar, position, true)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
-
- var event = helper.fireMousedown(helper.slider.selBar, offset, true);
-
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+
+ var event = helper.fireMousedown(helper.slider.selBar, position, true)
+
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
describe('Right to left Mouse controls - Range Vertical', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -263,213 +291,236 @@
floor: 0,
ceil: 100,
vertical: true,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on maxH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('highValue');
- expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('highValue')
+ expect(helper.slider.maxH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.min).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on maxH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.max).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 80,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
- expect(helper.scope.slider.min).to.equal(60);
- expect(helper.scope.slider.max).to.equal(80);
- });
+ expect(helper.scope.slider.min).to.equal(60)
+ expect(helper.scope.slider.max).to.equal(80)
+ })
it('should handle click and drag on maxH and switch min/max if needed', function() {
- helper.scope.slider.min = 40;
- helper.scope.slider.max = 60;
- helper.scope.$digest();
+ helper.scope.slider.min = 40
+ helper.scope.slider.max = 60
+ helper.scope.$digest()
- var event = helper.fireMousedown(helper.slider.maxH, 0, true);
+ var event = helper.fireMousedown(helper.slider.maxH, 0, true)
var expectedValue = 20,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
- helper.fireMousemove(offset, true);
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ helper.fireMousemove(position, true)
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(40);
- });
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(40)
+ })
it('should handle click on fullbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on fullbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH when click pos is nearer to minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.selBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.selBar, position, true)
- expect(helper.scope.slider.min).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.min).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move maxH when click pos is nearer to maxH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+ sinon.spy(helper.slider, 'focusElement')
var expectedValue = 90,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
-
- var event = helper.fireMousedown(helper.slider.selBar, offset, true);
-
- expect(helper.scope.slider.max).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('highValue');
- helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
-}());
-
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+
+ var event = helper.fireMousedown(helper.slider.selBar, position, true)
+
+ expect(helper.scope.slider.max).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('highValue')
+ helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/restricted-range-slider-test.js b/tests/specs/mouse-controls/restricted-range-slider-test.js
new file mode 100644
index 0000000..13e2b68
--- /dev/null
+++ b/tests/specs/mouse-controls/restricted-range-slider-test.js
@@ -0,0 +1,145 @@
+;(function() {
+ 'use strict'
+
+ describe('Mouse controls - Restricted Range', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ min: 25,
+ max: 85,
+ options: {
+ floor: 0,
+ ceil: 100,
+ restrictedRange: {
+ from: 30,
+ to: 70,
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
+
+ afterEach(function() {
+ // to clean document listener
+ helper.fireMouseup()
+ })
+
+ it('should be able to modify minH below restrictedRange.from', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var attemptedValue = 25
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.min).to.equal(25)
+ })
+
+ it('should not be able to modify minH above restrictedRange.from', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var attemptedValue = 40
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.min).to.equal(30)
+ })
+
+ it('should be able to modify maxH above restrictedRange.to', function() {
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var attemptedValue = 78
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.max).to.equal(78)
+ })
+
+ it('should not be able to modify maxH below restrictedRange.to', function() {
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var attemptedValue = 50
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.max).to.equal(70)
+ })
+ })
+
+ describe('Right to left Mouse controls - minLimit!=null && maxLimit!=null Range Horizontal', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ min: 45,
+ max: 55,
+ options: {
+ floor: 0,
+ ceil: 100,
+ restrictedRange: {
+ from: 30,
+ to: 70,
+ },
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
+ afterEach(function() {
+ // to clean document listener
+ helper.fireMouseup()
+ })
+
+ it('should be able to modify minH below restrictedRange.from', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var attemptedValue = 25
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.min).to.equal(25)
+ })
+
+ it('should not be able to modify minH above restrictedRange.from', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var attemptedValue = 40
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.min).to.equal(30)
+ })
+
+ it('should be able to modify maxH above restrictedRange.to', function() {
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var attemptedValue = 78
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.max).to.equal(78)
+ })
+
+ it('should not be able to modify maxH below restrictedRange.to', function() {
+ helper.fireMousedown(helper.slider.maxH, 0)
+ var attemptedValue = 50
+ helper.moveMouseToValue(attemptedValue)
+ expect(helper.scope.slider.max).to.equal(70)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/single-slider-horizontal-test.js b/tests/specs/mouse-controls/single-slider-horizontal-test.js
index db774a8..501cb28 100644
--- a/tests/specs/mouse-controls/single-slider-horizontal-test.js
+++ b/tests/specs/mouse-controls/single-slider-horizontal-test.js
@@ -1,412 +1,523 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
+ var sliderConf = {
+ value: 0,
+ options: {
+ floor: 0,
+ ceil: 100,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+ afterEach(function() {
+ // to clean document listener
+ helper.fireMouseup()
+ })
+
+ it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
+
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
+
+ it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
+
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
+
+ it('should handle click and drag on minH correctly when mouse is on the middle', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50,
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+
+ it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function() {
+ helper.scope.slider.value = 50
+ helper.scope.$digest()
+
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ helper.fireMousemove(-100)
+ expect(helper.scope.slider.value).to.equal(0)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
+
+ it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ helper.fireMousemove(helper.slider.maxPos + 100)
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
+
+ it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function() {
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+ helper.fireMouseup()
+
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
+
+ it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function() {
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+
+ helper.fireMouseup()
+
+ expect(helper.slider.tracking).to.equal('')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
+
+ it('should handle click on fullbar and move minH', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+
+ var expectedValue = 12,
+ position = helper.getMousePosition(expectedValue)
+
+ helper.fireMousedown(helper.slider.fullBar, position)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
- beforeEach(module('test-helper'));
+ it('should handle click on selbar and move minH', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
- beforeEach(inject(function (TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var expectedValue = 12,
+ position = helper.getMousePosition(expectedValue)
+
+ var event = helper.fireMousedown(helper.slider.selBar, position)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+
+ it('should handle click on ticks and move minH', function() {
+ helper.scope.slider.options.step = 10
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
+
+ var expectedValue = 10,
+ position = helper.getMousePosition(expectedValue)
+
+ helper.fireMousedown(helper.slider.ticks, position)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
- afterEach(function () {
- helper.clean();
- });
+ it('should handle click on ticks when showTicks is an integer and move minH', function() {
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.showTicks = 10
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
- beforeEach(function () {
+ var expectedValue = 10,
+ position = helper.getMousePosition(expectedValue)
+
+ helper.fireMousedown(helper.slider.ticks, position)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
+
+ describe('Right to left Mouse controls - Single Horizontal', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ beforeEach(function() {
var sliderConf = {
value: 0,
options: {
floor: 0,
- ceil: 100
- }
- };
- helper.createSlider(sliderConf);
- });
- afterEach(function () {
+ ceil: 100,
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+ afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
-
- it('should handle mousedown on minH correctly when keyboardSupport is true', function () {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
-
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
-
- it('should handle mousedown on minH correctly when keyboardSupport is false', function () {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
-
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
-
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is on the middle', function () {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
+ helper.fireMouseup()
+ })
+
+ it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
+
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
+
+ it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
+
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
+
+ it('should handle click and drag on minH correctly when mouse is on the middle', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
var expectedValue = 50,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function () {
- helper.scope.slider.value = 50;
- helper.scope.$digest();
-
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- helper.fireMousemove(-100);
- expect(helper.scope.slider.value).to.equal(0);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function () {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- helper.fireMousemove(helper.slider.maxPos + 100);
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
-
- it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function () {
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
- helper.fireMouseup();
-
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
-
- it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function () {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
-
- helper.fireMouseup();
-
- expect(helper.slider.tracking).to.equal('');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
-
- it('should handle click on fullbar and move minH', function () {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+
+ it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function() {
+ helper.scope.slider.value = 50
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ helper.fireMousemove(helper.slider.maxPos + 100)
+ expect(helper.scope.slider.value).to.equal(0)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
+
+ it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+ helper.fireMousemove(-100)
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
+
+ it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function() {
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+ helper.fireMouseup()
+
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
+
+ it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function() {
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+ var event = helper.fireMousedown(helper.slider.minH, 0)
+
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+
+ helper.fireMouseup()
+
+ expect(helper.slider.tracking).to.equal('')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
+
+ it('should handle click on fullbar and move minH', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 12,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- helper.fireMousedown(helper.slider.fullBar, offset);
+ helper.fireMousedown(helper.slider.fullBar, position)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
- it('should handle click on selbar and move minH', function () {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ it('should handle click on selbar and move minH', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 12,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- var event = helper.fireMousedown(helper.slider.selBar, offset);
+ var event = helper.fireMousedown(helper.slider.selBar, position)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
- it('should handle click on ticks and move minH', function () {
- helper.scope.slider.options.step = 10;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ it('should handle click on ticks and move minH', function() {
+ helper.scope.slider.options.step = 10
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
+ position = helper.getMousePosition(expectedValue)
- helper.fireMousedown(helper.slider.ticks, offset);
+ helper.fireMousedown(helper.slider.ticks, position)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
- it('should handle click on ticks when showTicks is an integer and move minH', function () {
- helper.scope.slider.options.step = 1;
- helper.scope.slider.options.showTicks = 10;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ it('should handle click on ticks when showTicks is an integer and move minH', function() {
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.showTicks = 10
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
-
- helper.fireMousedown(helper.slider.ticks, offset);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
-
- describe('Right to left Mouse controls - Single Horizontal', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
-
- afterEach(function() {
- helper.clean();
- });
-
- beforeEach(function() {
- var sliderConf = {
- value: 0,
- options: {
- floor: 0,
- ceil: 100,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
- afterEach(function() {
- // to clean document listener
- helper.fireMouseup();
- });
-
- it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
-
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
-
- it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
-
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
-
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- var expectedValue = 50,
- offset = helper.getMousePosition(expectedValue);
- helper.fireMousemove(offset);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function() {
- helper.scope.slider.value = 50;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- helper.fireMousemove(helper.slider.maxPos + 100);
- expect(helper.scope.slider.value).to.equal(0);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
-
- it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0);
- helper.fireMousemove(-100);
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
-
- it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function() {
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
- helper.fireMouseup();
-
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
-
- it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
- var event = helper.fireMousedown(helper.slider.minH, 0);
-
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
-
- helper.fireMouseup();
-
- expect(helper.slider.tracking).to.equal('');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
-
- it('should handle click on fullbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
-
- var expectedValue = 12,
- offset = helper.getMousePosition(expectedValue);
-
- helper.fireMousedown(helper.slider.fullBar, offset);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
-
- it('should handle click on selbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
-
- var expectedValue = 12,
- offset = helper.getMousePosition(expectedValue);
-
- var event = helper.fireMousedown(helper.slider.selBar, offset);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
-
- it('should handle click on ticks and move minH', function() {
- helper.scope.slider.options.step = 10;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
-
- var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
-
- helper.fireMousedown(helper.slider.ticks, offset);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
-
- it('should handle click on ticks when showTicks is an integer and move minH', function() {
- helper.scope.slider.options.step = 1;
- helper.scope.slider.options.showTicks = 10;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
-
- var expectedValue = 10,
- offset = helper.getMousePosition(expectedValue);
-
- helper.fireMousedown(helper.slider.ticks, offset);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
-}());
-
+ position = helper.getMousePosition(expectedValue)
+
+ helper.fireMousedown(helper.slider.ticks, position)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+
+ it('should handle touch start, touch move and touch end correctly when multitouch with originalEvent', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+
+ // Touch start for the slider
+ helper.fireTouchstartWithOriginalEvent(helper.slider.minH, 0, 0, [0])
+
+ var expectedValue = 50
+ var touchPositionForSlider = helper.getMousePosition(expectedValue)
+ // Touch move for the slider
+ helper.fireTouchmoveWithOriginalEvent(touchPositionForSlider, 0, [0, 1])
+
+ // Simultaneous touch move but not on slider
+ var otherTouchPosition = touchPositionForSlider + 100
+ helper.fireTouchmoveWithOriginalEvent(otherTouchPosition, 1, [0, 1])
+
+ // The slider does not react
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+
+ // The other simultaneous touch ends
+ helper.fireTouchendWithOriginalEvent(1, [0, 1])
+
+ var expectedValue = 60
+ var touchPositionForSlider = helper.getMousePosition(expectedValue)
+ // Touch move for the slider
+ helper.fireTouchmoveWithOriginalEvent(touchPositionForSlider, 0, [0, 1])
+
+ // Can still drag the slider
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+
+ // Slider touch ends
+ helper.fireTouchendWithOriginalEvent(0, [0, 1])
+
+ // Touch move for the slider
+ var touchPositionForSlider = helper.getMousePosition(70)
+ helper.fireTouchmoveWithOriginalEvent(touchPositionForSlider, 0, [0, 1])
+
+ // Can not drag the slider anymore
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
+
+ it('should handle touch start, touch move and touch end correctly when multitouch without originalEvent', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+
+ // Touch start for the slider
+ var eventOnSlider = helper.fireTouchstartWithoutOriginalEvent(
+ helper.slider.minH,
+ 0,
+ 0,
+ [0]
+ )
+
+ var expectedValue = 50
+ var touchPositionForSlider = helper.getMousePosition(expectedValue)
+ // Touch move for the slider
+ helper.fireTouchmoveWithoutOriginalEvent(touchPositionForSlider, 0, [
+ 0,
+ 1,
+ ])
+
+ // Simultaneous touch move but not on slider
+ var otherTouchPosition = touchPositionForSlider + 100
+ helper.fireTouchmoveWithoutOriginalEvent(otherTouchPosition, 1, [0, 1])
+
+ // The slider does not react
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+
+ // The other simultaneous touch ends
+ helper.fireTouchendWithoutOriginalEvent(1, [0, 1])
+
+ var expectedValue = 60
+ var touchPositionForSlider = helper.getMousePosition(expectedValue)
+ // Touch move for slider
+ helper.fireTouchmoveWithoutOriginalEvent(touchPositionForSlider, 0, [
+ 0,
+ 1,
+ ])
+
+ // Can still drag the slider
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+
+ // Slider touch ends
+ helper.fireTouchendWithoutOriginalEvent(0, [0, 1])
+
+ // Touch move for the slider
+ var touchPositionForSlider = helper.getMousePosition(70)
+ helper.fireTouchmoveWithoutOriginalEvent(touchPositionForSlider, 0, [
+ 0,
+ 1,
+ ])
+
+ // Can not drag the slider anymore
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
+ })
+})()
diff --git a/tests/specs/mouse-controls/single-slider-vertical-test.js b/tests/specs/mouse-controls/single-slider-vertical-test.js
index a7c132c..897711a 100644
--- a/tests/specs/mouse-controls/single-slider-vertical-test.js
+++ b/tests/specs/mouse-controls/single-slider-vertical-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Mouse controls - Single Vertical', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -26,206 +28,223 @@
options: {
floor: 0,
ceil: 100,
- vertical: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ vertical: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.minH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function() {
- helper.scope.slider.value = 50;
- helper.scope.$digest();
+ helper.scope.slider.value = 50
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
- helper.fireMousemove(helper.slider.maxPos + 100, true);
- expect(helper.scope.slider.value).to.equal(0);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
+ helper.fireMousemove(helper.slider.maxPos + 100, true)
+ expect(helper.scope.slider.value).to.equal(0)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
- helper.fireMousemove(-100, true);
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
+ helper.fireMousemove(-100, true)
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function() {
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
- helper.fireMouseup();
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+ helper.fireMouseup()
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
- helper.fireMouseup();
+ helper.fireMouseup()
- expect(helper.slider.tracking).to.equal('');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
+ expect(helper.slider.tracking).to.equal('')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
it('should handle click on fullbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 12,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousedown(helper.slider.selBar, offset, true);
+ helper.fireMousedown(helper.slider.selBar, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on ticks and move minH', function() {
- helper.scope.slider.options.step = 10;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ helper.scope.slider.options.step = 10
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousedown(helper.slider.ticks, offset, true);
+ helper.fireMousedown(helper.slider.ticks, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on ticks when showTicks is an integer and move minH', function() {
- helper.scope.slider.options.step = 1;
- helper.scope.slider.options.showTicks = 10;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.showTicks = 10
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousedown(helper.slider.ticks, offset, true);
+ helper.fireMousedown(helper.slider.ticks, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+ })
describe('Right to left Mouse controls - Single Vertical', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -234,187 +253,360 @@
floor: 0,
ceil: 100,
vertical: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
afterEach(function() {
// to clean document listener
- helper.fireMouseup();
- });
+ helper.fireMouseup()
+ })
it('should handle mousedown on minH correctly when keyboardSupport is true', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle mousedown on minH correctly when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'focusElement');
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'focusElement')
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- helper.slider.calcViewDimensions.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.focusElement.called.should.be.false;
- event.preventDefault.called.should.be.true;
- event.stopPropagation.called.should.be.true;
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- });
+ helper.slider.calcViewDimensions.called.should.be.true
+ helper.slider.callOnStart.called.should.be.true
+ helper.slider.focusElement.called.should.be.false
+ event.preventDefault.called.should.be.true
+ event.stopPropagation.called.should.be.true
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ })
it('should handle click and drag on minH correctly when mouse is on the middle', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnChange');
- helper.fireMousedown(helper.slider.minH, 0, true);
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ helper.fireMousedown(helper.slider.minH, 0, true)
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousemove(offset, true);
- expect(helper.scope.slider.value).to.equal(expectedValue);
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ helper.fireMousemove(position, true)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click and drag on minH correctly when mouse is before the slider and previous value was different than 0', function() {
- helper.scope.slider.value = 50;
- helper.scope.$digest();
+ helper.scope.slider.value = 50
+ helper.scope.$digest()
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
- helper.fireMousemove(-100, true);
- expect(helper.scope.slider.value).to.equal(0);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
+ helper.fireMousemove(-100, true)
+ expect(helper.scope.slider.value).to.equal(0)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
it('should handle click and drag on minH correctly when mouse is after the slider and previous value was different than 100', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
- helper.fireMousemove(helper.slider.maxPos + 100, true);
- expect(helper.scope.slider.value).to.equal(100);
- helper.slider.positionTrackingHandle.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
+ helper.fireMousemove(helper.slider.maxPos + 100, true)
+ expect(helper.scope.slider.value).to.equal(100)
+ helper.slider.positionTrackingHandle.called.should.be.true
+ })
it('should call correct callbacks on slider end and keep handle focused when keyboardSupport is true', function() {
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
- helper.fireMouseup();
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
+ helper.fireMouseup()
- expect(helper.slider.tracking).to.equal('lowValue');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.true
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
it('should call correct callbacks on slider end and not keep handle focused when keyboardSupport is false', function() {
- helper.scope.slider.options.keyboardSupport = false;
- helper.scope.$digest();
- var event = helper.fireMousedown(helper.slider.minH, 0, true);
+ helper.scope.slider.options.keyboardSupport = false
+ helper.scope.$digest()
+ var event = helper.fireMousedown(helper.slider.minH, 0, true)
- sinon.spy(helper.slider, 'callOnEnd');
- sinon.spy(helper.slider.scope, '$emit');
+ sinon.spy(helper.slider, 'callOnEnd')
+ sinon.spy(helper.slider.scope, '$emit')
- helper.fireMouseup();
+ helper.fireMouseup()
- expect(helper.slider.tracking).to.equal('');
- expect(helper.slider.minH.hasClass('rz-active')).to.be.false;
- helper.slider.callOnEnd.called.should.be.true;
- helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
- });
+ expect(helper.slider.tracking).to.equal('')
+ expect(helper.slider.minH.hasClass('rz-active')).to.be.false
+ helper.slider.callOnEnd.called.should.be.true
+ helper.slider.scope.$emit.calledWith('slideEnded').should.be.true
+ })
it('should handle click on fullbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 50,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
+ var event = helper.fireMousedown(helper.slider.fullBar, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on selbar and move minH', function() {
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 12,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousedown(helper.slider.selBar, offset, true);
+ helper.fireMousedown(helper.slider.selBar, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on ticks and move minH', function() {
- helper.scope.slider.options.step = 10;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ helper.scope.slider.options.step = 10
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
- helper.fireMousedown(helper.slider.ticks, offset, true);
+ helper.fireMousedown(helper.slider.ticks, position, true)
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
it('should handle click on ticks when showTicks is an integer and move minH', function() {
- helper.scope.slider.options.step = 1;
- helper.scope.slider.options.showTicks = 10;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'positionTrackingHandle');
- sinon.spy(helper.slider, 'callOnStart');
- sinon.spy(helper.slider, 'callOnChange');
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.showTicks = 10
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnStart')
+ sinon.spy(helper.slider, 'callOnChange')
var expectedValue = 10,
- offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
-
- helper.fireMousedown(helper.slider.ticks, offset, true);
-
- expect(helper.scope.slider.value).to.equal(expectedValue);
- expect(helper.slider.tracking).to.equal('lowValue');
- helper.slider.positionTrackingHandle.called.should.be.true;
- helper.slider.callOnStart.called.should.be.true;
- helper.slider.callOnChange.called.should.be.true;
- });
- });
-
-}());
-
+ position =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+
+ helper.fireMousedown(helper.slider.ticks, position, true)
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.tracking).to.equal('lowValue')
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnStart.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+ })
+
+ it('should handle touch start, touch move and touch end correctly when multitouch with originalEvent', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+ // Touch start for the slider
+ var eventOnSlider = helper.fireTouchstartWithOriginalEvent(
+ helper.slider.minH,
+ 0,
+ 0,
+ [0],
+ true
+ )
+
+ var expectedValue = 50
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+
+ // Touch move for the slider
+ helper.fireTouchmoveWithOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ // Simultaneous touch move but not on slider
+ var otherTouchPosition = touchPositionForSlider + 100
+ helper.fireTouchmoveWithOriginalEvent(otherTouchPosition, 1, [0, 1], true)
+
+ // The slider does not react
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+
+ // The other simultaneous touch ends
+ helper.fireTouchendWithOriginalEvent(1, [0, 1], true)
+
+ var expectedValue = 60
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ // Touch move for the slider
+ helper.fireTouchmoveWithOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ // Can still drag the slider
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+
+ // Slider touch ends
+ helper.fireTouchendWithOriginalEvent(0, [0, 1], true)
+
+ // Touch move for the slider
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(70) -
+ helper.slider.handleHalfDim
+ helper.fireTouchmoveWithOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ //Can not drag the slider anymore
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
+
+ it('should handle touch start, touch move and touch end correctly when multitouch without originalEvent', function() {
+ sinon.spy(helper.slider, 'positionTrackingHandle')
+ sinon.spy(helper.slider, 'callOnChange')
+
+ // Touch start for the slider
+ var eventOnSlider = helper.fireTouchstartWithoutOriginalEvent(
+ helper.slider.minH,
+ 0,
+ 0,
+ [0],
+ true
+ )
+ var expectedValue = 50
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+
+ // Touch move for slider
+ helper.fireTouchmoveWithoutOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ // Simultaneous touch move but not on slider
+ var otherTouchPosition = touchPositionForSlider + 100
+ helper.fireTouchmoveWithoutOriginalEvent(
+ otherTouchPosition,
+ 1,
+ [0, 1],
+ true
+ )
+
+ // The slider does not react
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(1)
+ expect(helper.slider.callOnChange.callCount).to.equal(1)
+
+ // The other simultaneous touch ends
+ helper.fireTouchendWithoutOriginalEvent(1, [0, 1], true)
+
+ var expectedValue = 60
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(expectedValue) -
+ helper.slider.handleHalfDim
+ // Touch move for slider
+ helper.fireTouchmoveWithoutOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ // Can still drag the slider
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+
+ // Slider touch ends
+ helper.fireTouchendWithoutOriginalEvent(0, [0, 1], true)
+
+ // Touch move for the slider
+ var touchPositionForSlider =
+ helper.slider.sliderElem.rzsp -
+ helper.slider.valueToPosition(70) -
+ helper.slider.handleHalfDim
+
+ // Can not drag the slider anymore
+ helper.fireTouchmoveWithoutOriginalEvent(
+ touchPositionForSlider,
+ 0,
+ [0, 1],
+ true
+ )
+
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ expect(helper.slider.positionTrackingHandle.callCount).to.equal(2)
+ expect(helper.slider.callOnChange.callCount).to.equal(2)
+ })
+ })
+})()
diff --git a/tests/specs/options-handling-test.js b/tests/specs/options-handling-test.js
index 18adf04..e64bc4d 100644
--- a/tests/specs/options-handling-test.js
+++ b/tests/specs/options-handling-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Options handling - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
describe('tests with same config', function() {
beforeEach(function() {
@@ -27,245 +29,307 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('horizontal slider should take the full width and get correct position/dimension properties', function() {
- helper.scope.$digest();
- expect(helper.element[0].getBoundingClientRect().width).to.equal(1000);
- expect(helper.slider.positionProperty).to.equal('left');
- expect(helper.slider.dimensionProperty).to.equal('width');
- expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.false;
- });
+ helper.scope.$digest()
+ expect(helper.element[0].getBoundingClientRect().width).to.equal(1000)
+ expect(helper.slider.positionProperty).to.equal('left')
+ expect(helper.slider.dimensionProperty).to.equal('width')
+ expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.false
+ })
it('vertical slider should take the full height and get correct position/dimension properties', function() {
- helper.scope.$digest();
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- expect(helper.element[0].getBoundingClientRect().height).to.equal(1000);
- expect(helper.slider.positionProperty).to.equal('bottom');
- expect(helper.slider.dimensionProperty).to.equal('height');
- expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.true;
- });
+ helper.scope.$digest()
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ expect(helper.element[0].getBoundingClientRect().height).to.equal(1000)
+ expect(helper.slider.positionProperty).to.equal('bottom')
+ expect(helper.slider.dimensionProperty).to.equal('height')
+ expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.true
+ })
it('should prevent invalid step', function() {
- helper.scope.slider.options.step = 0;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
+ helper.scope.slider.options.step = 0
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
- helper.scope.slider.options.step = -1;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- });
+ helper.scope.slider.options.step = -1
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ })
it('should not round value to step if enforceStep is false', function() {
- helper.scope.slider.options.enforceStep = false;
- helper.scope.$digest();
+ helper.scope.slider.options.enforceStep = false
+ helper.scope.$digest()
- helper.scope.slider.value = 14;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(14);
- });
+ helper.scope.slider.value = 14
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(14)
+ })
it('should round value to step if enforceStep is true', function() {
- helper.scope.slider.options.enforceStep = true;
- helper.scope.$digest();
+ helper.scope.slider.options.enforceStep = true
+ helper.scope.$digest()
- helper.scope.slider.value = 14;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(10);
- });
+ helper.scope.slider.value = 14
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should set the showTicks scope flag to true when showTicks is true', function() {
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- expect(helper.slider.scope.showTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ expect(helper.slider.scope.showTicks).to.be.true
+ })
it('should set the showTicks scope flag to true when showTicksValues is true', function() {
- helper.scope.slider.options.showTicksValues = true;
- helper.scope.$digest();
- expect(helper.slider.scope.showTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicksValues = true
+ helper.scope.$digest()
+ expect(helper.slider.scope.showTicks).to.be.true
+ })
it('should set not accept draggableRange to true when slider is a single one', function() {
- helper.scope.slider.options.draggableRange = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.false;
- });
+ helper.scope.slider.options.draggableRange = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.false
+ })
it('should set not accept draggableRangeOnly to true when slider is a single one', function() {
- helper.scope.slider.options.draggableRangeOnly = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.false;
- expect(helper.slider.options.draggableRangeOnly).to.be.false;
- });
+ helper.scope.slider.options.draggableRangeOnly = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.false
+ expect(helper.slider.options.draggableRangeOnly).to.be.false
+ })
it('should set correct step/floor/ceil and translate function when stepsArray is used with values', function() {
- helper.scope.slider.value = 'C';
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(2);
- });
+ helper.scope.slider.value = 'C'
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(2)
+ })
it('should set correct step/floor/ceil and translate function when stepsArray is used with values and bindIndexForStepsArray is true', function() {
- helper.scope.slider.value = 2;
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(2);
- });
+ helper.scope.slider.value = 2
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(2)
+ })
it('should set correct step/floor/ceil when stepsArray is used with values and ticks', function() {
- helper.scope.slider.value = 'C';
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(2);
- });
+ helper.scope.slider.value = 'C'
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(2)
+ })
it('should set correct step/floor/ceil when stepsArray is used with objects', function() {
- helper.scope.slider.value = 'D';
+ helper.scope.slider.value = 'D'
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B'},
- {value: 'C'},
- {value: 'D'},
- {value: 'E'}
- ];
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(3);
- });
+ { value: 'A' },
+ { value: 'B' },
+ { value: 'C' },
+ { value: 'D' },
+ { value: 'E' },
+ ]
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(3)
+ })
it('should set correct step/floor/ceil when stepsArray is used with objects and bindIndexForStepsArray is true', function() {
- helper.scope.slider.value = 3;
+ helper.scope.slider.value = 3
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B'},
- {value: 'C'},
- {value: 'D'},
- {value: 'E'}
- ];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(3);
- });
+ { value: 'A' },
+ { value: 'B' },
+ { value: 'C' },
+ { value: 'D' },
+ { value: 'E' },
+ ]
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(3)
+ })
it('should set correct step/floor/ceil function when stepsArray is used with objects containing legends', function() {
- helper.scope.slider.value = 'D';
+ helper.scope.slider.value = 'D'
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B', legend: 'Legend B'},
- {value: 'C'},
- {value: 'D', legend: 'Legend D'},
- {value: 'E'}
- ];
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
-
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(3);
-
- expect(helper.slider.getLegend(1)).to.equal('Legend B');
- expect(helper.slider.getLegend(3)).to.equal('Legend D');
-
- expect(helper.element[0].querySelectorAll('.rz-tick-legend')).to.have.length(2);
- });
+ { value: 'A' },
+ { value: 'B', legend: 'Legend B' },
+ { value: 'C' },
+ { value: 'D', legend: 'Legend D' },
+ { value: 'E' },
+ ]
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(3)
+
+ expect(helper.slider.getLegend(1)).to.equal('Legend B')
+ expect(helper.slider.getLegend(3)).to.equal('Legend D')
+
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-legend')
+ ).to.have.length(2)
+ })
it('should set correct step/floor/ceil function when stepsArray is used with objects containing legends and bindIndexForStepsArray is true', function() {
- helper.scope.slider.value = 3;
+ helper.scope.slider.value = 3
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B', legend: 'Legend B'},
- {value: 'C'},
- {value: 'D', legend: 'Legend D'},
- {value: 'E'}
- ];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
-
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(3);
-
- expect(helper.slider.getLegend(1)).to.equal('Legend B');
- expect(helper.slider.getLegend(3)).to.equal('Legend D');
-
- expect(helper.element[0].querySelectorAll('.rz-tick-legend')).to.have.length(2);
- });
+ { value: 'A' },
+ { value: 'B', legend: 'Legend B' },
+ { value: 'C' },
+ { value: 'D', legend: 'Legend D' },
+ { value: 'E' },
+ ]
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(3)
+
+ expect(helper.slider.getLegend(1)).to.equal('Legend B')
+ expect(helper.slider.getLegend(3)).to.equal('Legend D')
+
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-legend')
+ ).to.have.length(2)
+ })
+
+ it('should set correct step/floor/ceil when stepsArray is used with Date using same instances', function() {
+ var dates = []
+ for (var i = 1; i <= 7; i++) {
+ dates.push(new Date(2016, 7, i))
+ }
+ helper.scope.slider.value = dates[3]
+ helper.scope.slider.options.stepsArray = dates
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(6)
+ expect(helper.slider.lowValue).to.equal(3)
+ })
+
+ it('should set correct step/floor/ceil when stepsArray is used with Date using different instances', function() {
+ var dates = []
+ for (var i = 1; i <= 7; i++) {
+ dates.push(new Date(2016, 7, i))
+ }
+ helper.scope.slider.value = new Date(2016, 7, 4)
+ helper.scope.slider.options.stepsArray = dates
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(6)
+ expect(helper.slider.lowValue).to.equal(3)
+ })
+
+ it('should set correct step/floor/ceil when stepsArray is used with Object with Date values using different instances', function() {
+ var dates = []
+ for (var i = 1; i <= 7; i++) {
+ dates.push(new Date(2016, 7, i))
+ }
+ helper.scope.slider.value = new Date(2016, 7, 4)
+ helper.scope.slider.options.stepsArray = dates.map(function(val) {
+ return { value: val }
+ })
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(6)
+ expect(helper.slider.lowValue).to.equal(3)
+ })
it('should allow a custom translate function when stepsArray is used', function() {
helper.scope.slider.options.stepsArray = [
- {value: 'A', 'foo': 'barA'},
- {value: 'B', 'foo': 'barB'},
- {value: 'C', 'foo': 'barC'}
- ];
- helper.scope.slider.options.translate = function(value, sliderId, label) {
- return 'value: '+ value
- };
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(2);
-
- expect(helper.slider.customTrFn('A')).to.equal('value: A');
- expect(helper.slider.customTrFn('C')).to.equal('value: C');
- });
+ { value: 'A', foo: 'barA' },
+ { value: 'B', foo: 'barB' },
+ { value: 'C', foo: 'barC' },
+ ]
+ helper.scope.slider.options.translate = function(
+ value,
+ sliderId,
+ label
+ ) {
+ return 'value: ' + value
+ }
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(2)
+
+ expect(helper.slider.customTrFn('A')).to.equal('value: A')
+ expect(helper.slider.customTrFn('C')).to.equal('value: C')
+ })
it('should allow a custom translate function when stepsArray is used and bindIndexForStepsArray is true', function() {
- helper.scope.slider.options.stepsArray = [{'foo': 'barA'}, {'foo': 'barB'}, {'foo': 'barC'}];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.slider.options.translate = function(value, sliderId, label) {
- if (value >= 0 && value < helper.scope.slider.options.stepsArray.length) {
- return helper.scope.slider.options.stepsArray[value]['foo'];
- }
- else {
+ helper.scope.slider.options.stepsArray = [
+ { foo: 'barA' },
+ { foo: 'barB' },
+ { foo: 'barC' },
+ ]
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.slider.options.translate = function(
+ value,
+ sliderId,
+ label
+ ) {
+ if (
+ value >= 0 &&
+ value < helper.scope.slider.options.stepsArray.length
+ ) {
+ return helper.scope.slider.options.stepsArray[value]['foo']
+ } else {
return ''
}
- };
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(2);
+ }
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(2)
- expect(helper.slider.customTrFn(0)).to.equal('barA');
- expect(helper.slider.customTrFn(2)).to.equal('barC');
- });
+ expect(helper.slider.customTrFn(0)).to.equal('barA')
+ expect(helper.slider.customTrFn(2)).to.equal('barC')
+ })
it('should sanitize rzSliderModel between floor and ceil', function() {
- helper.scope.slider.options.enforceRange = true;
- helper.scope.slider.value = 1000;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(100);
-
- helper.scope.slider.value = -1000;
- helper.scope.$digest();
- $timeout.flush(); //to flush the throttle function
- expect(helper.scope.slider.value).to.equal(0);
- });
- });
+ helper.scope.slider.options.enforceRange = true
+ helper.scope.slider.value = 1000
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(100)
+
+ helper.scope.slider.value = -1000
+ helper.scope.$digest()
+ $timeout.flush() //to flush the throttle function
+ expect(helper.scope.slider.value).to.equal(0)
+ })
+ })
describe('tests with specific config', function() {
it('should accept custom translate function', function() {
@@ -276,31 +340,31 @@
ceil: 100,
step: 10,
translate: function(v) {
- return 'custom value';
- }
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.customTrFn(0)).to.equal('custom value');
- expect(helper.slider.customTrFn(100)).to.equal('custom value');
- });
+ return 'custom value'
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.customTrFn(0)).to.equal('custom value')
+ expect(helper.slider.customTrFn(100)).to.equal('custom value')
+ })
it('should set maxValue to rzSliderModel if no ceil is set for a single slider', function() {
var sliderConf = {
- value: 10
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.maxValue).to.equal(10);
- });
+ value: 10,
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.maxValue).to.equal(10)
+ })
it('should set maxValue to rzSliderHigh if no ceil is set for a range slider', function() {
var sliderConf = {
min: 10,
- max: 100
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.maxValue).to.equal(100);
- });
+ max: 100,
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.maxValue).to.equal(100)
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBar=true', function() {
var sliderConf = {
@@ -308,14 +372,19 @@
options: {
floor: 0,
ceil: 10,
- showSelectionBar: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal('0px');
- });
+ showSelectionBar: true,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension =
+ Math.round(helper.slider.valueToPosition(2)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('width')).to.equal(
+ expectedDimension + 'px'
+ )
+ expect(helper.slider.selBar.css('left')).to.equal('0px')
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarEnd=true', function() {
var sliderConf = {
@@ -323,15 +392,26 @@
options: {
floor: 0,
ceil: 10,
- showSelectionBarEnd: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(8) + helper.slider.handleHalfDim,
- expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ showSelectionBarEnd: true,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.floor(
+ helper.slider.valueToPosition(8) + helper.slider.handleHalfDim
+ ),
+ actualDimension = Math.floor(
+ helper.slider.selBar[0].getBoundingClientRect().width
+ )
+ expect(actualDimension).to.equal(expectedDimension)
+
+ var expectedPosition =
+ Math.round(helper.slider.valueToPosition(2)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarFromValue is used with a value on the right', function() {
var sliderConf = {
@@ -339,15 +419,22 @@
options: {
floor: 0,
ceil: 20,
- showSelectionBarFromValue: 10
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(5),
- expectedPosition = helper.slider.valueToOffset(10) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ showSelectionBarFromValue: 10,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.round(helper.slider.valueToPosition(5)),
+ expectedPosition =
+ Math.round(helper.slider.valueToPosition(10)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('width')).to.equal(
+ expectedDimension + 'px'
+ )
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarFromValue is used with a value on the left', function() {
var sliderConf = {
@@ -355,52 +442,108 @@
options: {
floor: 0,
ceil: 20,
- showSelectionBarFromValue: 10
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(7),
- expectedPosition = helper.slider.valueToOffset(3) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ showSelectionBarFromValue: 10,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.round(helper.slider.valueToPosition(7)),
+ actualDimension = Math.round(
+ helper.slider.selBar[0].getBoundingClientRect().width
+ )
+ expect(actualDimension).to.equal(expectedDimension)
+
+ var expectedPosition =
+ Math.round(helper.slider.valueToPosition(3)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
+
+ it('should set the correct background position for selection bar for range slider when selectionBarGradient is used with a value {from: "white"; to:"blue"}', function() {
+ var sliderConf = {
+ min: 5,
+ max: 10,
+ options: {
+ floor: 0,
+ ceil: 20,
+ selectionBarGradient: {
+ from: 'white',
+ to: 'blue',
+ },
+ },
+ }
+
+ helper.createRangeSlider(sliderConf)
+
+ var expectedPosition =
+ -(
+ Math.round(helper.slider.valueToPosition(5)) +
+ helper.slider.handleHalfDim
+ ) + 'px center',
+ actualPosition = helper.slider.scope.barStyle.backgroundPosition
+ expect(actualPosition).to.equal(expectedPosition)
+ })
+
+ it('should set the correct gradient for selection bar for slider when selectionBarGradient is used with a value {from: "white"; to:"blue"} and vertical is used with a value true', function() {
+ var sliderConf = {
+ value: 5,
+ options: {
+ floor: 0,
+ ceil: 20,
+ vertical: true,
+ showSelectionBar: true,
+ selectionBarGradient: {
+ from: 'white',
+ to: 'blue',
+ },
+ },
+ }
+
+ helper.createSlider(sliderConf)
+
+ var expectedGradient = 'linear-gradient(to top, white 0%,blue 100%)',
+ actualGradient = helper.slider.scope.barStyle.backgroundImage
+ expect(actualGradient).to.equal(expectedGradient)
+ })
it('should set alwaysHide on floor/ceil when hideLimitLabels is set to true', function() {
var sliderConf = {
value: 10,
options: {
- hideLimitLabels: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.rzAlwaysHide).to.be.true;
- expect(helper.slider.ceilLab.rzAlwaysHide).to.be.true;
- });
+ hideLimitLabels: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.rzAlwaysHide).to.be.true
+ expect(helper.slider.ceilLab.rzAlwaysHide).to.be.true
+ })
it('should set alwaysHide on minLab when hidePointerLabels is set to true on a single slider', function() {
var sliderConf = {
value: 10,
options: {
- hidePointerLabels: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.minLab.rzAlwaysHide).to.be.true;
- });
+ hidePointerLabels: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.minLab.rzAlwaysHide).to.be.true
+ })
it('should set alwaysHide on minLab when hidePointerLabels is set to true on a single slider', function() {
var sliderConf = {
min: 10,
max: 100,
options: {
- hidePointerLabels: true
- }
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.minLab.rzAlwaysHide).to.be.true;
- expect(helper.slider.maxLab.rzAlwaysHide).to.be.true;
- expect(helper.slider.cmbLab.rzAlwaysHide).to.be.true;
- });
+ hidePointerLabels: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.minLab.rzAlwaysHide).to.be.true
+ expect(helper.slider.maxLab.rzAlwaysHide).to.be.true
+ expect(helper.slider.cmbLab.rzAlwaysHide).to.be.true
+ })
it('should show floor and ceil labels when hidePointerLabels is true', function() {
var sliderConf = {
@@ -408,13 +551,13 @@
options: {
floor: 0,
ceil: 100,
- hidePointerLabels: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ hidePointerLabels: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should show floor and ceil labels when hidePointerLabels is true, for range slider', function() {
var sliderConf = {
@@ -423,13 +566,13 @@
options: {
floor: 0,
ceil: 100,
- hidePointerLabels: true
- }
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.flrLab.css('visibility')).to.equal('visible');
- expect(helper.slider.ceilLab.css('visibility')).to.equal('visible');
- });
+ hidePointerLabels: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.flrLab.css('visibility')).to.equal('visible')
+ expect(helper.slider.ceilLab.css('visibility')).to.equal('visible')
+ })
it('should set the correct background-color on selection bar for single slider', function() {
var sliderConf = {
@@ -439,19 +582,21 @@
ceil: 10,
showSelectionBar: true,
getSelectionBarColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
- }
- }
- };
- helper.createSlider(sliderConf);
- var selBarChild = angular.element(helper.slider.selBar[0].querySelector('.rz-selection'));
- expect(selBarChild.css('background-color')).to.equal('green');
-
- helper.scope.slider.value = 2;
- helper.scope.$digest();
- expect(selBarChild.css('background-color')).to.equal('red');
- });
+ if (v < 5) return 'red'
+ return 'green'
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var selBarChild = angular.element(
+ helper.slider.selBar[0].querySelector('.rz-selection')
+ )
+ expect(selBarChild.css('background-color')).to.equal('green')
+
+ helper.scope.slider.value = 2
+ helper.scope.$digest()
+ expect(selBarChild.css('background-color')).to.equal('red')
+ })
it('should set the correct dimension/position for selection bar for range slider', function() {
var sliderConf = {
@@ -459,15 +604,24 @@
max: 8,
options: {
floor: 0,
- ceil: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(6),
- expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ ceil: 10,
+ disableAnimation: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+
+ var expectedDimension = Math.round(helper.slider.valueToPosition(6)),
+ actualDimension = helper.slider.selBar[0].getBoundingClientRect()
+ .width
+ expect(actualDimension).to.equal(expectedDimension)
+
+ var expectedPosition =
+ Math.round(helper.slider.valueToPosition(2)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct background-color on selection bar for range slider', function() {
var sliderConf = {
@@ -477,84 +631,90 @@
floor: 0,
ceil: 10,
getSelectionBarColor: function(min, max) {
- if (max - min < 5) return 'red';
- return 'green';
- }
- }
- };
- helper.createRangeSlider(sliderConf);
- var selBarChild = angular.element(helper.slider.selBar[0].querySelector('.rz-selection'));
- expect(selBarChild.css('background-color')).to.equal('green');
-
- helper.scope.slider.min = 4;
- helper.scope.slider.max = 6;
- helper.scope.$digest();
- expect(selBarChild.css('background-color')).to.equal('red');
- });
+ if (max - min < 5) return 'red'
+ return 'green'
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ var selBarChild = angular.element(
+ helper.slider.selBar[0].querySelector('.rz-selection')
+ )
+ expect(selBarChild.css('background-color')).to.equal('green')
+
+ helper.scope.slider.min = 4
+ helper.scope.slider.max = 6
+ helper.scope.$digest()
+ expect(selBarChild.css('background-color')).to.equal('red')
+ })
it('should call the correct callback for onStart', function() {
var sliderConf = {
value: 10,
options: {
id: 'test',
- onStart: sinon.spy()
- }
- };
- helper.createSlider(sliderConf);
+ onStart: sinon.spy(),
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.tracking = 'lowValue';
- helper.slider.callOnStart();
- $timeout.flush();
- sliderConf.options.onStart.calledWith('test', 10, undefined, 'min').should.be.true;
- });
+ helper.slider.tracking = 'lowValue'
+ helper.slider.callOnStart()
+ $timeout.flush()
+ sliderConf.options.onStart.calledWith('test', 10, undefined, 'min')
+ .should.be.true
+ })
it('should call the correct callback for onStart called on high handle', function() {
var sliderConf = {
value: 10,
options: {
id: 'test',
- onStart: sinon.spy()
- }
- };
- helper.createSlider(sliderConf);
+ onStart: sinon.spy(),
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.tracking = 'highValue';
- helper.slider.callOnStart();
- $timeout.flush();
- sliderConf.options.onStart.calledWith('test', 10, undefined, 'max').should.be.true;
- });
+ helper.slider.tracking = 'highValue'
+ helper.slider.callOnStart()
+ $timeout.flush()
+ sliderConf.options.onStart.calledWith('test', 10, undefined, 'max')
+ .should.be.true
+ })
it('should call the correct callback for onChange', function() {
var sliderConf = {
value: 10,
options: {
id: 'test',
- onChange: sinon.spy()
- }
- };
- helper.createSlider(sliderConf);
+ onChange: sinon.spy(),
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.tracking = 'lowValue';
- helper.slider.callOnChange();
- $timeout.flush();
- sliderConf.options.onChange.calledWith('test', 10, undefined, 'min').should.be.true;
- });
+ helper.slider.tracking = 'lowValue'
+ helper.slider.callOnChange()
+ $timeout.flush()
+ sliderConf.options.onChange.calledWith('test', 10, undefined, 'min')
+ .should.be.true
+ })
it('should call the correct callback for onEnd', function() {
var sliderConf = {
value: 10,
options: {
id: 'test',
- onEnd: sinon.spy()
- }
- };
- helper.createSlider(sliderConf);
+ onEnd: sinon.spy(),
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.tracking = 'lowValue';
- helper.slider.callOnEnd();
- $timeout.flush();
- sliderConf.options.onEnd.calledWith('test', 10, undefined, 'min').should.be.true;
- });
+ helper.slider.tracking = 'lowValue'
+ helper.slider.callOnEnd()
+ $timeout.flush()
+ sliderConf.options.onEnd.calledWith('test', 10, undefined, 'min').should
+ .be.true
+ })
it('should set the correct background-color on pointer for single slider', function() {
var sliderConf = {
@@ -564,19 +724,19 @@
ceil: 10,
showSelectionBar: true,
getPointerColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
- }
- }
- };
- helper.createSlider(sliderConf);
- var minHChild = angular.element(helper.slider.minH[0]);
- expect(minHChild.css('background-color')).to.equal('green');
+ if (v < 5) return 'red'
+ return 'green'
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var minHChild = angular.element(helper.slider.minH[0])
+ expect(minHChild.css('background-color')).to.equal('green')
- helper.scope.slider.value = 2;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('red');
- });
+ helper.scope.slider.value = 2
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('red')
+ })
it('should set the correct background-color on pointer for range slider (simple rule)', function() {
var sliderConf = {
@@ -586,23 +746,23 @@
floor: 0,
ceil: 10,
getPointerColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
- }
- }
- };
- helper.createRangeSlider(sliderConf);
+ if (v < 5) return 'red'
+ return 'green'
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('green');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('green')
- helper.scope.slider.min = 6;
- helper.scope.slider.max = 7;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('green');
- expect(maxHChild.css('background-color')).to.equal('green');
- });
+ helper.scope.slider.min = 6
+ helper.scope.slider.max = 7
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('green')
+ expect(maxHChild.css('background-color')).to.equal('green')
+ })
it('should set the correct background-color on pointer for range slider (min/high independent rule 1)', function() {
var sliderConf = {
@@ -613,27 +773,27 @@
ceil: 10,
getPointerColor: function(v, type) {
if (type === 'min') {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
}
if (type === 'max') {
- if (v < 5) return 'blue';
- return 'orange';
+ if (v < 5) return 'blue'
+ return 'orange'
}
- }
- }
- };
- helper.createRangeSlider(sliderConf);
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('orange');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('orange')
- helper.scope.slider.min = 6;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('green');
- });
+ helper.scope.slider.min = 6
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('green')
+ })
it('should set the correct background-color on pointer for range slider (min/high independent rule 2)', function() {
var sliderConf = {
@@ -644,29 +804,28 @@
ceil: 10,
getPointerColor: function(v, type) {
if (type === 'min') {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
}
if (type === 'max') {
- if (v < 5) return 'blue';
- return 'orange';
+ if (v < 5) return 'blue'
+ return 'orange'
}
- }
- }
- };
- helper.createRangeSlider(sliderConf);
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('orange');
-
- helper.scope.slider.max = 3;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('blue');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('orange')
- });
+ helper.scope.slider.max = 3
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('blue')
+ })
it('should set the correct background-color on tick', function() {
var sliderConf = {
@@ -676,18 +835,24 @@
ceil: 10,
showTicks: true,
getTickColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
- }
- }
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(11);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(firstTick[0].style['background-color']).to.equal('red');
- expect(lastTick[0].style['background-color']).to.equal('green');
- });
+ if (v < 5) return 'red'
+ return 'green'
+ },
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(
+ 11
+ )
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(firstTick[0].style['background-color']).to.equal('red')
+ expect(lastTick[0].style['background-color']).to.equal('green')
+ })
it('should set the correct position for labels for single slider with boundPointerLabels=false', function() {
var sliderConf = {
@@ -696,20 +861,31 @@
options: {
floor: 100000000,
ceil: 100001000,
- boundPointerLabels: false
- }
- };
-
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.minLab.css('left')).to.equal('-' + (helper.slider.minLab.rzsd / 2 - helper.slider.handleHalfDim) + 'px');
- expect(helper.slider.maxLab.css('left')).to.equal((helper.slider.barDimension - (helper.slider.maxLab.rzsd / 2 + helper.slider.handleHalfDim)) + 'px');
-
- sliderConf.max = 100000001;
- helper.createRangeSlider(sliderConf);
-
- expect(parseInt(helper.slider.cmbLab.css('left'))).to.be.below(0);
- });
- });
+ boundPointerLabels: false,
+ },
+ }
+
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.minLab.css('left')).to.equal(
+ '-' +
+ Math.round(
+ helper.slider.minLab.rzsd / 2 - helper.slider.handleHalfDim
+ ) +
+ 'px'
+ )
+ expect(helper.slider.maxLab.css('left')).to.equal(
+ Math.round(
+ helper.slider.barDimension -
+ (helper.slider.maxLab.rzsd / 2 + helper.slider.handleHalfDim)
+ ) + 'px'
+ )
+
+ sliderConf.max = 100000001
+ helper.createRangeSlider(sliderConf)
+
+ expect(parseInt(helper.slider.cmbLab.css('left'))).to.be.below(0)
+ })
+ })
describe('range slider specific - ', function() {
beforeEach(function() {
@@ -719,151 +895,151 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should set the correct class to true when draggableRange is true', function() {
- helper.scope.slider.options.draggableRange = true;
- helper.scope.$digest();
- expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true;
- });
+ helper.scope.slider.options.draggableRange = true
+ helper.scope.$digest()
+ expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true
+ })
it('should set draggableRange to true when draggableRangeOnly is true', function() {
- helper.scope.slider.options.draggableRangeOnly = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.true;
- expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true;
- });
+ helper.scope.slider.options.draggableRangeOnly = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.true
+ expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true
+ })
it('should sanitize rzSliderModel and rzSliderHigh between floor and ceil', function() {
- helper.scope.slider.options.enforceRange = true;
- helper.scope.slider.min = -1000;
- helper.scope.slider.max = 1000;
- helper.scope.$digest();
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(100);
- });
+ helper.scope.slider.options.enforceRange = true
+ helper.scope.slider.min = -1000
+ helper.scope.slider.max = 1000
+ helper.scope.$digest()
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(100)
+ })
it('should set correct step/floor/ceil and translate function when stepsArray is used with values', function() {
- helper.scope.slider.min = 'B';
- helper.scope.slider.max = 'D';
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ helper.scope.slider.min = 'B'
+ helper.scope.slider.max = 'D'
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set correct step/floor/ceil and translate function when stepsArray is used with values and bindIndexForStepsArray is true', function() {
- helper.scope.slider.min = 1;
- helper.scope.slider.max = 3;
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ helper.scope.slider.min = 1
+ helper.scope.slider.max = 3
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set correct step/floor/ceil when stepsArray is used with values and ticks', function() {
- helper.scope.slider.min = 'B';
- helper.scope.slider.max = 'D';
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ helper.scope.slider.min = 'B'
+ helper.scope.slider.max = 'D'
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set correct step/floor/ceil when stepsArray is used with values and ticks and bindIndexForStepsArray is true', function() {
- helper.scope.slider.min = 1;
- helper.scope.slider.max = 3;
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ helper.scope.slider.min = 1
+ helper.scope.slider.max = 3
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set correct step/floor/ceil when stepsArray is used with objects', function() {
- helper.scope.slider.min = 'B';
- helper.scope.slider.max = 'D';
+ helper.scope.slider.min = 'B'
+ helper.scope.slider.max = 'D'
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B'},
- {value: 'C'},
- {value: 'D'},
- {value: 'E'}
- ];
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ { value: 'A' },
+ { value: 'B' },
+ { value: 'C' },
+ { value: 'D' },
+ { value: 'E' },
+ ]
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set correct step/floor/ceil when stepsArray is used with objects and bindIndexForStepsArray is true', function() {
- helper.scope.slider.min = 1;
- helper.scope.slider.max = 3;
+ helper.scope.slider.min = 1
+ helper.scope.slider.max = 3
helper.scope.slider.options.stepsArray = [
- {value: 'A'},
- {value: 'B'},
- {value: 'C'},
- {value: 'D'},
- {value: 'E'}
- ];
- helper.scope.slider.options.bindIndexForStepsArray = true;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(1);
- expect(helper.slider.highValue).to.equal(3);
- });
+ { value: 'A' },
+ { value: 'B' },
+ { value: 'C' },
+ { value: 'D' },
+ { value: 'E' },
+ ]
+ helper.scope.slider.options.bindIndexForStepsArray = true
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(1)
+ expect(helper.slider.highValue).to.equal(3)
+ })
it('should set the correct combined label when range values are the same and mergeRangeLabelsIfSame option is false', function() {
- helper.scope.slider.options.mergeRangeLabelsIfSame = false;
- helper.scope.slider.min = 50;
- helper.scope.slider.max = 50;
- helper.scope.$digest();
- expect(helper.slider.cmbLab.text()).to.equal('50 - 50');
- });
+ helper.scope.slider.options.mergeRangeLabelsIfSame = false
+ helper.scope.slider.min = 50
+ helper.scope.slider.max = 50
+ helper.scope.$digest()
+ expect(helper.slider.cmbLab.text()).to.equal('50 - 50')
+ })
it('should set the correct combined label when range values are the same and mergeRangeLabelsIfSame option is true', function() {
- helper.scope.slider.options.mergeRangeLabelsIfSame = true;
- helper.scope.slider.min = 50;
- helper.scope.slider.max = 50;
- helper.scope.$digest();
- expect(helper.slider.cmbLab.text()).to.equal('50');
- });
- });
+ helper.scope.slider.options.mergeRangeLabelsIfSame = true
+ helper.scope.slider.min = 50
+ helper.scope.slider.max = 50
+ helper.scope.$digest()
+ expect(helper.slider.cmbLab.text()).to.equal('50')
+ })
+ })
describe('options expression specific - ', function() {
it('should safely handle null expressions', function() {
var sliderConf = {
value: 10,
- optionsExpression: 'thisDoesntExist'
- };
+ optionsExpression: 'thisDoesntExist',
+ }
- helper.createSlider(sliderConf);
- helper.scope.$digest();
- expect(helper.slider.step).to.equal(1);
- });
+ helper.createSlider(sliderConf)
+ helper.scope.$digest()
+ expect(helper.slider.step).to.equal(1)
+ })
it('should not cause an infinite $digest loop with an expression that always returns a new object', function() {
var sliderConf = {
@@ -871,38 +1047,40 @@
options: function() {
return {
floor: 1,
- ceil: 1000
- };
+ ceil: 1000,
+ }
},
- optionsExpression: 'slider.options()'
- };
+ optionsExpression: 'slider.options()',
+ }
- helper.createSlider(sliderConf);
- helper.scope.$digest();
- expect(helper.slider.minValue).to.equal(1);
- expect(helper.slider.maxValue).to.equal(1000);
- });
- });
- });
+ helper.createSlider(sliderConf)
+ helper.scope.$digest()
+ expect(helper.slider.minValue).to.equal(1)
+ expect(helper.slider.maxValue).to.equal(1000)
+ })
+ })
+ })
describe('Right to left Options handling - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
describe('tests with same config', function() {
beforeEach(function() {
@@ -912,117 +1090,117 @@
floor: 0,
ceil: 100,
step: 10,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('horizontal slider should take the full width and get correct position/dimension properties', function() {
- helper.scope.$digest();
- expect(helper.element[0].getBoundingClientRect().width).to.equal(1000);
- expect(helper.slider.positionProperty).to.equal('left');
- expect(helper.slider.dimensionProperty).to.equal('width');
- expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.false;
- });
+ helper.scope.$digest()
+ expect(helper.element[0].getBoundingClientRect().width).to.equal(1000)
+ expect(helper.slider.positionProperty).to.equal('left')
+ expect(helper.slider.dimensionProperty).to.equal('width')
+ expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.false
+ })
it('vertical slider should take the full height and get correct position/dimension properties', function() {
- helper.scope.$digest();
- helper.scope.slider.options.vertical = true;
- helper.scope.$digest();
- expect(helper.element[0].getBoundingClientRect().height).to.equal(1000);
- expect(helper.slider.positionProperty).to.equal('bottom');
- expect(helper.slider.dimensionProperty).to.equal('height');
- expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.true;
- });
+ helper.scope.$digest()
+ helper.scope.slider.options.vertical = true
+ helper.scope.$digest()
+ expect(helper.element[0].getBoundingClientRect().height).to.equal(1000)
+ expect(helper.slider.positionProperty).to.equal('bottom')
+ expect(helper.slider.dimensionProperty).to.equal('height')
+ expect(helper.slider.sliderElem.hasClass('rz-vertical')).to.be.true
+ })
it('should prevent invalid step', function() {
- helper.scope.slider.options.step = 0;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
+ helper.scope.slider.options.step = 0
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
- helper.scope.slider.options.step = -1;
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- });
+ helper.scope.slider.options.step = -1
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ })
it('should not round value to step if enforceStep is false', function() {
- helper.scope.slider.options.enforceStep = false;
- helper.scope.$digest();
+ helper.scope.slider.options.enforceStep = false
+ helper.scope.$digest()
- helper.scope.slider.value = 14;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(14);
- });
+ helper.scope.slider.value = 14
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(14)
+ })
it('should round value to step if enforceStep is true', function() {
- helper.scope.slider.options.enforceStep = true;
- helper.scope.$digest();
+ helper.scope.slider.options.enforceStep = true
+ helper.scope.$digest()
- helper.scope.slider.value = 14;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(10);
- });
+ helper.scope.slider.value = 14
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(10)
+ })
it('should set the showTicks scope flag to true when showTicks is true', function() {
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- expect(helper.slider.scope.showTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ expect(helper.slider.scope.showTicks).to.be.true
+ })
it('should set the showTicks scope flag to true when showTicksValues is true', function() {
- helper.scope.slider.options.showTicksValues = true;
- helper.scope.$digest();
- expect(helper.slider.scope.showTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicksValues = true
+ helper.scope.$digest()
+ expect(helper.slider.scope.showTicks).to.be.true
+ })
it('should set the intermediateTicks flag to true when showTicks is an integer', function() {
- helper.scope.slider.options.showTicks = 10;
- helper.scope.$digest();
- expect(helper.slider.intermediateTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicks = 10
+ helper.scope.$digest()
+ expect(helper.slider.intermediateTicks).to.be.true
+ })
it('should set the intermediateTicks flag to true when showTicksValues is an integer', function() {
- helper.scope.slider.options.showTicksValues = 10;
- helper.scope.$digest();
- expect(helper.slider.intermediateTicks).to.be.true;
- });
+ helper.scope.slider.options.showTicksValues = 10
+ helper.scope.$digest()
+ expect(helper.slider.intermediateTicks).to.be.true
+ })
it('should set not accept draggableRange to true when slider is a single one', function() {
- helper.scope.slider.options.draggableRange = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.false;
- });
+ helper.scope.slider.options.draggableRange = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.false
+ })
it('should set not accept draggableRangeOnly to true when slider is a single one', function() {
- helper.scope.slider.options.draggableRangeOnly = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.false;
- expect(helper.slider.options.draggableRangeOnly).to.be.false;
- });
+ helper.scope.slider.options.draggableRangeOnly = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.false
+ expect(helper.slider.options.draggableRangeOnly).to.be.false
+ })
it('should set correct step/floor/ceil and translate function when stepsArray is used', function() {
- helper.scope.slider.value = 'C';
- helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
- helper.scope.$digest();
- expect(helper.slider.options.step).to.equal(1);
- expect(helper.slider.options.floor).to.equal(0);
- expect(helper.slider.options.ceil).to.equal(4);
- expect(helper.slider.lowValue).to.equal(2);
- });
+ helper.scope.slider.value = 'C'
+ helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']
+ helper.scope.$digest()
+ expect(helper.slider.options.step).to.equal(1)
+ expect(helper.slider.options.floor).to.equal(0)
+ expect(helper.slider.options.ceil).to.equal(4)
+ expect(helper.slider.lowValue).to.equal(2)
+ })
it('should sanitize rzSliderModel between floor and ceil', function() {
- helper.scope.slider.options.enforceRange = true;
- helper.scope.slider.value = 1000;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(100);
-
- helper.scope.slider.value = -1000;
- helper.scope.$digest();
- $timeout.flush(); //to flush the throttle function
- expect(helper.scope.slider.value).to.equal(0);
- });
- });
+ helper.scope.slider.options.enforceRange = true
+ helper.scope.slider.value = 1000
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(100)
+
+ helper.scope.slider.value = -1000
+ helper.scope.$digest()
+ $timeout.flush() //to flush the throttle function
+ expect(helper.scope.slider.value).to.equal(0)
+ })
+ })
describe('tests with specific config', function() {
it('should accept custom translate function', function() {
@@ -1033,34 +1211,34 @@
ceil: 100,
step: 10,
translate: function(v) {
- return 'custom value';
+ return 'custom value'
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.customTrFn(0)).to.equal('custom value');
- expect(helper.slider.customTrFn(100)).to.equal('custom value');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.customTrFn(0)).to.equal('custom value')
+ expect(helper.slider.customTrFn(100)).to.equal('custom value')
+ })
it('should set maxValue to rzSliderModel if no ceil is set for a single slider', function() {
var sliderConf = {
value: 10,
- rightToLeft: true
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.maxValue).to.equal(10);
- });
+ rightToLeft: true,
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.maxValue).to.equal(10)
+ })
it('should set maxValue to rzSliderHigh if no ceil is set for a range slider', function() {
var sliderConf = {
min: 10,
max: 100,
- rightToLeft: true
- };
- helper.createRangeSlider(sliderConf);
- expect(helper.slider.maxValue).to.equal(100);
- });
+ rightToLeft: true,
+ }
+ helper.createRangeSlider(sliderConf)
+ expect(helper.slider.maxValue).to.equal(100)
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBar=true', function() {
var sliderConf = {
@@ -1069,15 +1247,24 @@
floor: 0,
ceil: 10,
showSelectionBar: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = Math.floor(helper.slider.valueToOffset(8) + helper.slider.handleHalfDim),
- actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
- expect(actualDimension).to.equal(expectedDimension);
- expect(helper.slider.selBar.css('left')).to.equal(helper.slider.valueToOffset(2) + helper.slider.handleHalfDim + 'px');
- });
+ rightToLeft: true,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.round(
+ helper.slider.valueToPosition(8) + helper.slider.handleHalfDim
+ ),
+ actualDimension = Math.round(
+ helper.slider.selBar[0].getBoundingClientRect().width
+ )
+ expect(actualDimension).to.equal(expectedDimension)
+ expect(helper.slider.selBar.css('left')).to.equal(
+ Math.round(helper.slider.valueToPosition(2)) +
+ helper.slider.handleHalfDim +
+ 'px'
+ )
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarEnd=true', function() {
var sliderConf = {
@@ -1086,14 +1273,20 @@
floor: 0,
ceil: 10,
showSelectionBarEnd: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal('0px');
- });
+ rightToLeft: true,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.floor(
+ helper.slider.valueToPosition(2) + helper.slider.handleHalfDim
+ ),
+ actualDimension = Math.floor(
+ helper.slider.selBar[0].getBoundingClientRect().width
+ )
+ expect(actualDimension).to.equal(expectedDimension)
+ expect(helper.slider.selBar.css('left')).to.equal('0px')
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarFromValue is used with a value on the left', function() {
var sliderConf = {
@@ -1102,15 +1295,21 @@
floor: 0,
ceil: 20,
showSelectionBarFromValue: 10,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(15),
- expectedPosition = helper.slider.valueToOffset(15) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.round(helper.slider.valueToPosition(15)),
+ expectedPosition =
+ Math.round(helper.slider.valueToPosition(15)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('width')).to.equal(
+ expectedDimension + 'px'
+ )
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarFromValue is used with a value on the right', function() {
var sliderConf = {
@@ -1119,16 +1318,22 @@
floor: 0,
ceil: 20,
showSelectionBarFromValue: 10,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var expectedDimension = Math.floor(helper.slider.valueToOffset(13)),
- actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width),
- expectedPosition = helper.slider.valueToOffset(10) + helper.slider.handleHalfDim;
- expect(actualDimension).to.equal(expectedDimension);
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ rightToLeft: true,
+ disableAnimation: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var expectedDimension = Math.round(helper.slider.valueToPosition(13)),
+ actualDimension = helper.slider.selBar[0].getBoundingClientRect()
+ .width,
+ expectedPosition =
+ Math.round(helper.slider.valueToPosition(10)) +
+ helper.slider.handleHalfDim
+ expect(actualDimension).to.equal(expectedDimension)
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct background-color on selection bar for single slider', function() {
var sliderConf = {
@@ -1138,20 +1343,22 @@
ceil: 10,
showSelectionBar: true,
getSelectionBarColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var selBarChild = angular.element(helper.slider.selBar[0].querySelector('.rz-selection'));
- expect(selBarChild.css('background-color')).to.equal('green');
-
- helper.scope.slider.value = 2;
- helper.scope.$digest();
- expect(selBarChild.css('background-color')).to.equal('red');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var selBarChild = angular.element(
+ helper.slider.selBar[0].querySelector('.rz-selection')
+ )
+ expect(selBarChild.css('background-color')).to.equal('green')
+
+ helper.scope.slider.value = 2
+ helper.scope.$digest()
+ expect(selBarChild.css('background-color')).to.equal('red')
+ })
it('should set the correct dimension/position for selection bar for range slider', function() {
var sliderConf = {
@@ -1159,16 +1366,25 @@
max: 8,
options: {
floor: 0,
- ceil: 10
+ ceil: 10,
+ disableAnimation: true,
},
- rightToLeft: true
- };
- helper.createRangeSlider(sliderConf);
- var expectedDimension = helper.slider.valueToOffset(6),
- expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
- expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
- expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
- });
+ rightToLeft: true,
+ }
+ helper.createRangeSlider(sliderConf)
+
+ var expectedDimension = Math.round(helper.slider.valueToPosition(6)),
+ actualDimension = helper.slider.selBar[0].getBoundingClientRect()
+ .width
+ expect(actualDimension).to.equal(expectedDimension)
+
+ var expectedPosition =
+ Math.round(helper.slider.valueToPosition(2)) +
+ helper.slider.handleHalfDim
+ expect(helper.slider.selBar.css('left')).to.equal(
+ expectedPosition + 'px'
+ )
+ })
it('should set the correct background-color on selection bar for range slider', function() {
var sliderConf = {
@@ -1178,21 +1394,23 @@
floor: 0,
ceil: 10,
getSelectionBarColor: function(min, max) {
- if (max - min < 5) return 'red';
- return 'green';
+ if (max - min < 5) return 'red'
+ return 'green'
},
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- var selBarChild = angular.element(helper.slider.selBar[0].querySelector('.rz-selection'));
- expect(selBarChild.css('background-color')).to.equal('green');
-
- helper.scope.slider.min = 4;
- helper.scope.slider.max = 6;
- helper.scope.$digest();
- expect(selBarChild.css('background-color')).to.equal('red');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ var selBarChild = angular.element(
+ helper.slider.selBar[0].querySelector('.rz-selection')
+ )
+ expect(selBarChild.css('background-color')).to.equal('green')
+
+ helper.scope.slider.min = 4
+ helper.scope.slider.max = 6
+ helper.scope.$digest()
+ expect(selBarChild.css('background-color')).to.equal('red')
+ })
it('should call the correct callback for onStart', function() {
var sliderConf = {
@@ -1200,15 +1418,15 @@
options: {
id: 'test',
onStart: sinon.spy(),
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.callOnStart();
- $timeout.flush();
- sliderConf.options.onStart.calledWith('test').should.be.true;
- });
+ helper.slider.callOnStart()
+ $timeout.flush()
+ sliderConf.options.onStart.calledWith('test').should.be.true
+ })
it('should call the correct callback for onChange', function() {
var sliderConf = {
@@ -1216,15 +1434,15 @@
options: {
id: 'test',
onChange: sinon.spy(),
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.callOnChange();
- $timeout.flush();
- sliderConf.options.onChange.calledWith('test').should.be.true;
- });
+ helper.slider.callOnChange()
+ $timeout.flush()
+ sliderConf.options.onChange.calledWith('test').should.be.true
+ })
it('should call the correct callback for onEnd', function() {
var sliderConf = {
@@ -1232,15 +1450,15 @@
options: {
id: 'test',
onEnd: sinon.spy(),
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
- helper.slider.callOnEnd();
- $timeout.flush();
- sliderConf.options.onEnd.calledWith('test').should.be.true;
- });
+ helper.slider.callOnEnd()
+ $timeout.flush()
+ sliderConf.options.onEnd.calledWith('test').should.be.true
+ })
it('should set the correct background-color on pointer for single slider', function() {
var sliderConf = {
@@ -1250,20 +1468,20 @@
ceil: 10,
showSelectionBar: true,
getPointerColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var minHChild = angular.element(helper.slider.minH[0]);
- expect(minHChild.css('background-color')).to.equal('green');
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var minHChild = angular.element(helper.slider.minH[0])
+ expect(minHChild.css('background-color')).to.equal('green')
- helper.scope.slider.value = 2;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('red');
- });
+ helper.scope.slider.value = 2
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('red')
+ })
it('should set the correct background-color on pointer for range slider (simple rule)', function() {
var sliderConf = {
@@ -1273,24 +1491,24 @@
floor: 0,
ceil: 10,
getPointerColor: function(v) {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
},
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('green');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('green')
- helper.scope.slider.min = 6;
- helper.scope.slider.max = 7;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('green');
- expect(maxHChild.css('background-color')).to.equal('green');
- });
+ helper.scope.slider.min = 6
+ helper.scope.slider.max = 7
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('green')
+ expect(maxHChild.css('background-color')).to.equal('green')
+ })
it('should set the correct background-color on pointer for range slider (min/high independent rule 1)', function() {
var sliderConf = {
@@ -1301,28 +1519,28 @@
ceil: 10,
getPointerColor: function(v, type) {
if (type === 'min') {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
}
if (type === 'max') {
- if (v < 5) return 'blue';
- return 'orange';
+ if (v < 5) return 'blue'
+ return 'orange'
}
},
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('orange');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('orange')
- helper.scope.slider.min = 6;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('green');
- });
+ helper.scope.slider.min = 6
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('green')
+ })
it('should set the correct background-color on pointer for range slider (min/high independent rule 2)', function() {
var sliderConf = {
@@ -1333,30 +1551,29 @@
ceil: 10,
getPointerColor: function(v, type) {
if (type === 'min') {
- if (v < 5) return 'red';
- return 'green';
+ if (v < 5) return 'red'
+ return 'green'
}
if (type === 'max') {
- if (v < 5) return 'blue';
- return 'orange';
+ if (v < 5) return 'blue'
+ return 'orange'
}
},
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
var minHChild = angular.element(helper.slider.minH[0]),
- maxHChild = angular.element(helper.slider.maxH[0]);
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('orange');
-
- helper.scope.slider.max = 3;
- helper.scope.$digest();
- expect(minHChild.css('background-color')).to.equal('red');
- expect(maxHChild.css('background-color')).to.equal('blue');
+ maxHChild = angular.element(helper.slider.maxH[0])
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('orange')
- });
+ helper.scope.slider.max = 3
+ helper.scope.$digest()
+ expect(minHChild.css('background-color')).to.equal('red')
+ expect(maxHChild.css('background-color')).to.equal('blue')
+ })
it('should correctly link the customTemplateScope properties on slider scope', function() {
var sliderConf = {
@@ -1364,15 +1581,15 @@
options: {
customTemplateScope: {
a: 1,
- b: 'test'
- }
- }
- };
- helper.createSlider(sliderConf);
+ b: 'test',
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
expect(helper.slider.scope.custom.a).to.equal(1)
expect(helper.slider.scope.custom.b).to.equal('test')
- });
- });
+ })
+ })
describe('range slider specific - ', function() {
beforeEach(function() {
@@ -1383,46 +1600,113 @@
floor: 0,
ceil: 100,
step: 10,
- rightToLeft: true
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should set the correct class to true when draggableRange is true', function() {
- helper.scope.slider.options.draggableRange = true;
- helper.scope.$digest();
- expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true;
- });
+ helper.scope.slider.options.draggableRange = true
+ helper.scope.$digest()
+ expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true
+ })
it('should set draggableRange to true when draggableRangeOnly is true', function() {
- helper.scope.slider.options.draggableRangeOnly = true;
- helper.scope.$digest();
- expect(helper.slider.options.draggableRange).to.be.true;
- expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true;
- });
+ helper.scope.slider.options.draggableRangeOnly = true
+ helper.scope.$digest()
+ expect(helper.slider.options.draggableRange).to.be.true
+ expect(helper.slider.selBar.hasClass('rz-draggable')).to.be.true
+ })
it('should sanitize rzSliderModel and rzSliderHigh between floor and ceil', function() {
- helper.scope.slider.options.enforceRange = true;
- helper.scope.slider.min = -1000;
- helper.scope.slider.max = 1000;
- helper.scope.$digest();
- expect(helper.scope.slider.min).to.equal(0);
- expect(helper.scope.slider.max).to.equal(100);
- });
- });
+ helper.scope.slider.options.enforceRange = true
+ helper.scope.slider.min = -1000
+ helper.scope.slider.max = 1000
+ helper.scope.$digest()
+ expect(helper.scope.slider.min).to.equal(0)
+ expect(helper.scope.slider.max).to.equal(100)
+ })
+
+ it('should visualize left/right outer selection', function() {
+ helper.scope.slider.min = 30
+ helper.scope.slider.max = 70
+ helper.scope.slider.options.showOuterSelectionBars = true
+ helper.scope.slider.options.rightToLeft = false
+ helper.scope.$digest()
+ expect(helper.slider.leftOutSelBar.css('visibility')).to.equal(
+ 'visible'
+ )
+ expect(helper.slider.rightOutSelBar.css('visibility')).to.equal(
+ 'visible'
+ )
+ expect(helper.slider.fullBar.hasClass('rz-transparent')).to.be.true
+ })
+
+ it('should swap left/right outer selection in rightToLeft mode', function() {
+ helper.scope.slider.min = 30
+ helper.scope.slider.max = 70
+ helper.scope.slider.options.showOuterSelectionBars = true
+ helper.scope.slider.options.rightToLeft = true
+ helper.scope.$digest()
+ expect(helper.slider.leftOutSelBar.css('visibility')).to.equal(
+ 'visible'
+ )
+ expect(helper.slider.rightOutSelBar.css('visibility')).to.equal(
+ 'visible'
+ )
+ expect(helper.slider.fullBar.hasClass('rz-transparent')).to.be.true
+ // rightToLeft checking
+ expect(parseInt(helper.slider.rightOutSelBar.css('left'))).to.be.below(
+ parseInt(helper.slider.leftOutSelBar.css('left'))
+ )
+ })
+
+ it('should use the default separator when labels overlap', function() {
+ helper.scope.slider.min = -1
+ helper.scope.slider.max = 1
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = +100
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.rightToLeft = false
+ helper.scope.$digest()
+ expect(helper.slider.cmbLab.text()).to.equal('-1 - 1')
+ })
+
+ it('should use the custom separator when labels overlap, and labelOverlapSeparator is set', function() {
+ helper.scope.slider.min = -1
+ helper.scope.slider.max = 1
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = +100
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.rightToLeft = false
+ helper.scope.slider.options.labelOverlapSeparator = ' .. '
+ helper.scope.$digest()
+ expect(helper.slider.cmbLab.text()).to.equal('-1 .. 1')
+ })
+ it('should use the custom separator when labels overlap, and labelOverlapSeparator is set, in RTL mode', function() {
+ helper.scope.slider.min = -1
+ helper.scope.slider.max = 1
+ helper.scope.slider.options.floor = -100
+ helper.scope.slider.options.ceil = +100
+ helper.scope.slider.options.step = 1
+ helper.scope.slider.options.labelOverlapSeparator = ' .. '
+ helper.scope.$digest()
+ expect(helper.slider.cmbLab.text()).to.equal('1 .. -1')
+ })
+ })
describe('options expression specific - ', function() {
it('should safely handle null expressions', function() {
var sliderConf = {
value: 10,
- optionsExpression: 'thisDoesntExist'
- };
+ optionsExpression: 'thisDoesntExist',
+ }
- helper.createSlider(sliderConf);
- helper.scope.$digest();
- expect(helper.slider.step).to.equal(1);
- });
+ helper.createSlider(sliderConf)
+ helper.scope.$digest()
+ expect(helper.slider.step).to.equal(1)
+ })
it('should not cause an infinite $digest loop with an expression that always returns a new object', function() {
var sliderConf = {
@@ -1430,18 +1714,42 @@
options: function() {
return {
floor: 1,
- ceil: 1000
- };
+ ceil: 1000,
+ }
+ },
+ optionsExpression: 'slider.options()',
+ }
+
+ helper.createSlider(sliderConf)
+ helper.scope.$digest()
+ expect(helper.slider.minValue).to.equal(1)
+ expect(helper.slider.maxValue).to.equal(1000)
+ })
+ })
+
+ describe('reacting to changes - ', function() {
+ beforeEach(function() {
+ var sliderConf = {
+ value: 10,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ translate: function(val) {
+ return val + '%'
+ },
},
- optionsExpression: 'slider.options()'
- };
-
- helper.createSlider(sliderConf);
- helper.scope.$digest();
- expect(helper.slider.minValue).to.equal(1);
- expect(helper.slider.maxValue).to.equal(1000);
- });
- });
- });
-
-}());
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should react to changes of options which are functions', function() {
+ helper.scope.slider.options.translate = function(val) {
+ return val + '$'
+ }
+ helper.scope.$digest()
+ expect(helper.slider.customTrFn(100)).to.equal('100$')
+ })
+ })
+ })
+})()
diff --git a/tests/specs/range-slider-init-test.js b/tests/specs/range-slider-init-test.js
index 5ddee72..1d201dd 100644
--- a/tests/specs/range-slider-init-test.js
+++ b/tests/specs/range-slider-init-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Range slider initialisation - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
+ var helper, RzSliderOptions, $rootScope, $timeout
- beforeEach(module('test-helper'));
+ beforeEach(module('test-helper'))
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -27,78 +29,77 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createRangeSlider(sliderConf);
- });
+ step: 10,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ })
it('should exist compiled and with correct config', function() {
- expect(helper.element.find('span')).to.have.length(11);
- expect(helper.slider.range).to.be.true;
- expect(helper.slider.valueRange).to.equal(100);
- expect(helper.slider.maxH.css('display')).to.equal('');
- });
+ expect(helper.element.find('span')).to.have.length(17)
+ expect(helper.slider.range).to.be.true
+ expect(helper.slider.valueRange).to.equal(100)
+ expect(helper.slider.maxH.css('display')).to.equal('')
+ })
it('should watch rzSliderHigh and reflow the slider accordingly', function() {
- sinon.spy(helper.slider, 'onHighHandleChange');
- helper.scope.slider.max = 95;
- helper.scope.$digest();
- helper.slider.onHighHandleChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'onHighHandleChange')
+ helper.scope.slider.max = 95
+ helper.scope.$digest()
+ helper.slider.onHighHandleChange.called.should.be.true
+ })
it('should switch to a single slider when rzSliderHigh is unset after init', function() {
- sinon.spy(helper.slider, 'onHighHandleChange');
- sinon.spy(helper.slider, 'applyOptions');
- sinon.spy(helper.slider, 'resetSlider');
- helper.scope.slider.max = undefined;
- helper.scope.$digest();
- helper.slider.onHighHandleChange.called.should.be.false;
- helper.slider.applyOptions.called.should.be.true;
- helper.slider.resetSlider.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'onHighHandleChange')
+ sinon.spy(helper.slider, 'applyOptions')
+ sinon.spy(helper.slider, 'resetSlider')
+ helper.scope.slider.max = undefined
+ helper.scope.$digest()
+ helper.slider.onHighHandleChange.called.should.be.false
+ helper.slider.applyOptions.called.should.be.true
+ helper.slider.resetSlider.called.should.be.true
+ })
it('should switch to a range slider when rzSliderHigh is set after init', function() {
- helper.scope.slider.max = undefined;
- helper.scope.$digest();
- sinon.spy(helper.slider, 'onHighHandleChange');
- sinon.spy(helper.slider, 'applyOptions');
- sinon.spy(helper.slider, 'resetSlider');
- helper.scope.slider.max = 100;
- helper.scope.$digest();
- helper.slider.onHighHandleChange.called.should.be.true;
- helper.slider.applyOptions.called.should.be.true;
- helper.slider.resetSlider.called.should.be.true;
- });
+ helper.scope.slider.max = undefined
+ helper.scope.$digest()
+ sinon.spy(helper.slider, 'onHighHandleChange')
+ sinon.spy(helper.slider, 'applyOptions')
+ sinon.spy(helper.slider, 'resetSlider')
+ helper.scope.slider.max = 100
+ helper.scope.$digest()
+ helper.slider.onHighHandleChange.called.should.be.true
+ helper.slider.applyOptions.called.should.be.true
+ helper.slider.resetSlider.called.should.be.true
+ })
it('should round the model value to the step', function() {
- helper.scope.slider.min = 23;
- helper.scope.slider.max = 84;
- helper.scope.$digest();
- expect(helper.scope.slider.min).to.equal(20);
- expect(helper.scope.slider.max).to.equal(80);
+ helper.scope.slider.min = 23
+ helper.scope.slider.max = 84
+ helper.scope.$digest()
+ expect(helper.scope.slider.min).to.equal(20)
+ expect(helper.scope.slider.max).to.equal(80)
- helper.scope.slider.min = 25;
- helper.scope.slider.max = 95;
- helper.scope.$digest();
- $timeout.flush(); //to flush the throttle function
- expect(helper.scope.slider.min).to.equal(30);
- expect(helper.scope.slider.max).to.equal(100);
- });
+ helper.scope.slider.min = 25
+ helper.scope.slider.max = 95
+ helper.scope.$digest()
+ $timeout.flush() //to flush the throttle function
+ expect(helper.scope.slider.min).to.equal(30)
+ expect(helper.scope.slider.max).to.equal(100)
+ })
it('should reset everything on rzSliderForceRender', function() {
- sinon.spy(helper.slider, 'resetLabelsValue');
- sinon.spy(helper.slider, 'resetSlider');
- sinon.spy(helper.slider, 'onLowHandleChange');
- sinon.spy(helper.slider, 'onHighHandleChange');
+ sinon.spy(helper.slider, 'resetLabelsValue')
+ sinon.spy(helper.slider, 'resetSlider')
+ sinon.spy(helper.slider, 'onLowHandleChange')
+ sinon.spy(helper.slider, 'onHighHandleChange')
- helper.scope.$broadcast('rzSliderForceRender');
-
- helper.slider.resetLabelsValue.called.should.be.true;
- helper.slider.resetSlider.called.should.be.true;
- helper.slider.onLowHandleChange.called.should.be.true;
- helper.slider.onHighHandleChange.called.should.be.true;
- });
- });
-}());
+ helper.scope.$broadcast('rzSliderForceRender')
+ helper.slider.resetLabelsValue.called.should.be.true
+ helper.slider.resetSlider.called.should.be.true
+ helper.slider.onLowHandleChange.called.should.be.true
+ helper.slider.onHighHandleChange.called.should.be.true
+ })
+ })
+})()
diff --git a/tests/specs/rz-slider-options-test.js b/tests/specs/rz-slider-options-test.js
index f90d2f1..03dafb4 100644
--- a/tests/specs/rz-slider-options-test.js
+++ b/tests/specs/rz-slider-options-test.js
@@ -1,48 +1,48 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('RzSliderOptions - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
it('should have a correct getOptions method that apply custom options', function() {
- var defaultOpts = RzSliderOptions.getOptions();
+ var defaultOpts = RzSliderOptions.getOptions()
var customOpts = {
- showTicks: true
- };
+ showTicks: true,
+ }
- var expectedOpts = angular.extend({}, defaultOpts, customOpts);
- var options = RzSliderOptions.getOptions(customOpts);
- expect(options).to.deep.equal(expectedOpts);
- });
+ var expectedOpts = angular.extend({}, defaultOpts, customOpts)
+ var options = RzSliderOptions.getOptions(customOpts)
+ expect(options).to.deep.equal(expectedOpts)
+ })
it('should have a correct options method to update the global options', function() {
-
- var defaultOpts = RzSliderOptions.getOptions();
+ var defaultOpts = RzSliderOptions.getOptions()
var globalOpts = {
- showTicks: true
- };
- RzSliderOptions.options(globalOpts);
-
- var expectedOpts = angular.extend({}, defaultOpts, globalOpts);
- var options = RzSliderOptions.getOptions();
- expect(options).to.deep.equal(expectedOpts);
- });
- });
-}());
-
+ showTicks: true,
+ }
+ RzSliderOptions.options(globalOpts)
+
+ var expectedOpts = angular.extend({}, defaultOpts, globalOpts)
+ var options = RzSliderOptions.getOptions()
+ expect(options).to.deep.equal(expectedOpts)
+ })
+ })
+})()
diff --git a/tests/specs/scale-test.js b/tests/specs/scale-test.js
new file mode 100644
index 0000000..e1824de
--- /dev/null
+++ b/tests/specs/scale-test.js
@@ -0,0 +1,158 @@
+;(function() {
+ 'use strict'
+
+ describe('Scale test - ', function() {
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
+
+ afterEach(function() {
+ helper.clean()
+ })
+
+ describe('Linear scale - ', function() {
+ beforeEach(function() {
+ var sliderConf = {
+ value: 10,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should have a correct linearValueToPosition', function() {
+ var actual = helper.slider.linearValueToPosition(0, 0, 50)
+ expect(actual).to.equal(0)
+ actual = helper.slider.linearValueToPosition(25, 0, 50)
+ expect(actual.toFixed(2)).to.equal('0.50')
+ actual = helper.slider.linearValueToPosition(50, 0, 50)
+ expect(actual).to.equal(1)
+ })
+
+ it('should have a correct linearPositionToValue', function() {
+ var actual = helper.slider.linearPositionToValue(0, 0, 50)
+ expect(actual).to.equal(0)
+ actual = helper.slider.linearPositionToValue(0.5, 0, 50)
+ expect(actual).to.equal(25)
+ actual = Math.round(helper.slider.linearPositionToValue(1, 0, 50))
+ expect(actual).to.equal(50)
+ })
+ })
+
+ describe('Logarithm scale - ', function() {
+ beforeEach(function() {
+ var sliderConf = {
+ value: 10,
+ options: {
+ floor: 1,
+ ceil: 100,
+ step: 10,
+ logScale: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should throw an error if floor is 0', function() {
+ var testFn = function() {
+ helper.scope.slider.options.floor = 0
+ helper.scope.$digest()
+ }
+ expect(testFn).to.throw("Can't use floor=0 with logarithmic scale")
+ })
+
+ it('should have a correct logValueToPosition', function() {
+ var actual = helper.slider.logValueToPosition(1, 1, 50)
+ expect(actual).to.equal(0)
+ actual = helper.slider.logValueToPosition(25, 1, 50)
+ expect(actual.toFixed(2)).to.equal('0.82')
+ actual = helper.slider.logValueToPosition(50, 1, 50)
+ expect(actual).to.equal(1)
+ })
+
+ it('should have a correct logPositionToValue', function() {
+ var actual = helper.slider.logPositionToValue(0, 1, 50)
+ expect(actual).to.equal(1)
+ actual = helper.slider.logPositionToValue(0.5, 1, 50)
+ expect(actual.toFixed(2)).to.equal('7.07')
+ actual = Math.round(helper.slider.logPositionToValue(1, 1, 50))
+ expect(actual).to.equal(50)
+ })
+
+ it('should handle click and drag on minH correctly', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50,
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.value).to.equal(expectedValue + 1) // + 1 because we start at 1
+ })
+ })
+
+ describe('Custom scale (here a x^2 scale)- ', function() {
+ beforeEach(function() {
+ var sliderConf = {
+ value: 50,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ customValueToPosition: function(val, minVal, maxVal) {
+ val = Math.sqrt(val)
+ minVal = Math.sqrt(minVal)
+ maxVal = Math.sqrt(maxVal)
+ var range = maxVal - minVal
+ return (val - minVal) / range
+ },
+ customPositionToValue: function(percent, minVal, maxVal) {
+ minVal = Math.sqrt(minVal)
+ maxVal = Math.sqrt(maxVal)
+ var value = percent * (maxVal - minVal) + minVal
+ return Math.pow(value, 2)
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+ ;-it('should have a correct valueToPosition', function() {
+ var actual = helper.slider.valueToPosition(0)
+ expect(actual).to.equal(0)
+ actual = helper.slider.valueToPosition(25)
+ expect(actual).to.equal(helper.slider.maxPos / 2)
+ actual = helper.slider.valueToPosition(100)
+ expect(actual).to.equal(helper.slider.maxPos)
+ })
+
+ it('should have a correct positionToValue', function() {
+ var actual = helper.slider.positionToValue(0)
+ expect(actual).to.equal(0)
+ actual = helper.slider.positionToValue(helper.slider.maxPos / 2)
+ expect(actual).to.equal(25)
+ actual = Math.round(helper.slider.positionToValue(helper.slider.maxPos))
+ expect(actual).to.equal(100)
+ })
+
+ it('should handle click and drag on minH correctly', function() {
+ helper.fireMousedown(helper.slider.minH, 0)
+ var expectedValue = 50,
+ position = helper.getMousePosition(expectedValue)
+ helper.fireMousemove(position)
+ expect(helper.scope.slider.value).to.equal(expectedValue)
+ })
+ })
+ })
+})()
diff --git a/tests/specs/single-slider-init-test.js b/tests/specs/single-slider-init-test.js
index e416cce..35f6147 100644
--- a/tests/specs/single-slider-init-test.js
+++ b/tests/specs/single-slider-init-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Single slider initialisation - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
beforeEach(function() {
var sliderConf = {
@@ -26,80 +28,83 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
it('should exist compiled and with correct config', function() {
- expect(helper.element.find('span')).to.have.length(11);
- expect(helper.slider.range).to.be.false;
- expect(helper.slider.valueRange).to.equal(100);
- expect(helper.slider.maxH.css('display')).to.equal('none');
- });
+ expect(helper.element.find('span')).to.have.length(17)
+ expect(helper.slider.range).to.be.false
+ expect(helper.slider.valueRange).to.equal(100)
+ expect(helper.slider.maxH.css('display')).to.equal('none')
+ })
it('should watch rzSliderModel and reflow the slider accordingly', function() {
- sinon.spy(helper.slider, 'onLowHandleChange');
- helper.scope.slider.value = 54;
- helper.scope.$digest();
- helper.slider.onLowHandleChange.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'onLowHandleChange')
+ helper.scope.slider.value = 54
+ helper.scope.$digest()
+ helper.slider.onLowHandleChange.called.should.be.true
+ })
it('should watch rzSliderOptions and reset the slider accordingly', function() {
- sinon.spy(helper.slider, 'applyOptions');
- sinon.spy(helper.slider, 'resetSlider');
- helper.scope.slider.options.showTicks = true;
- helper.scope.$digest();
- helper.slider.applyOptions.called.should.be.true;
- helper.slider.resetSlider.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'applyOptions')
+ sinon.spy(helper.slider, 'resetSlider')
+ helper.scope.slider.options.showTicks = true
+ helper.scope.$digest()
+ helper.slider.applyOptions.called.should.be.true
+ helper.slider.resetSlider.called.should.be.true
+ })
it('should round the model value to the step by default', function() {
- helper.scope.slider.value = 54;
- helper.scope.$digest();
- expect(helper.scope.slider.value).to.equal(50);
+ helper.scope.slider.value = 54
+ helper.scope.$digest()
+ expect(helper.scope.slider.value).to.equal(50)
- helper.scope.slider.value = 55;
- helper.scope.$digest();
- $timeout.flush(); //to flush the throttle function since we modify twice in a row
- expect(helper.scope.slider.value).to.equal(60);
- });
+ helper.scope.slider.value = 55
+ helper.scope.$digest()
+ $timeout.flush() //to flush the throttle function since we modify twice in a row
+ expect(helper.scope.slider.value).to.equal(60)
+ })
it('should call calcViewDimensions() on reCalcViewDimensions', function() {
- sinon.spy(helper.slider, 'calcViewDimensions');
- helper.scope.$broadcast('reCalcViewDimensions');
- helper.slider.calcViewDimensions.called.should.be.true;
- });
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ helper.scope.$broadcast('reCalcViewDimensions')
+ helper.slider.calcViewDimensions.called.should.be.true
+ })
it('should reset everything on rzSliderForceRender', function() {
- sinon.spy(helper.slider, 'resetLabelsValue');
- sinon.spy(helper.slider, 'resetSlider');
- sinon.spy(helper.slider, 'onLowHandleChange');
-
- helper.scope.$broadcast('rzSliderForceRender');
-
- helper.slider.resetLabelsValue.called.should.be.true;
- helper.slider.resetSlider.called.should.be.true;
- helper.slider.onLowHandleChange.called.should.be.true;
- });
-
- it('should call calcViewDimensions() on window resize event', inject(function($window) {
- sinon.spy(helper.slider, 'calcViewDimensions');
- angular.element($window).triggerHandler('resize');
- helper.slider.calcViewDimensions.called.should.be.true;
- }));
-
- it('should unregister all dom events on $destroy', inject(function($window) {
- sinon.spy(helper.slider, 'calcViewDimensions');
- sinon.spy(helper.slider, 'unbindEvents');
-
- helper.scope.$broadcast('$destroy');
- angular.element($window).triggerHandler('resize');
-
- helper.slider.calcViewDimensions.called.should.be.false;
- helper.slider.unbindEvents.called.should.be.true;
- }));
- });
-}());
-
+ sinon.spy(helper.slider, 'resetLabelsValue')
+ sinon.spy(helper.slider, 'resetSlider')
+ sinon.spy(helper.slider, 'onLowHandleChange')
+
+ helper.scope.$broadcast('rzSliderForceRender')
+
+ helper.slider.resetLabelsValue.called.should.be.true
+ helper.slider.resetSlider.called.should.be.true
+ helper.slider.onLowHandleChange.called.should.be.true
+ })
+
+ it('should call calcViewDimensions() on window resize event', inject(function(
+ $window
+ ) {
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ angular.element($window).triggerHandler('resize')
+ helper.slider.calcViewDimensions.called.should.be.true
+ }))
+
+ it('should unregister all dom events on $destroy', inject(function(
+ $window
+ ) {
+ sinon.spy(helper.slider, 'calcViewDimensions')
+ sinon.spy(helper.slider, 'unbindEvents')
+
+ helper.scope.$broadcast('$destroy')
+ angular.element($window).triggerHandler('resize')
+
+ helper.slider.calcViewDimensions.called.should.be.false
+ helper.slider.unbindEvents.called.should.be.true
+ }))
+ })
+})()
diff --git a/tests/specs/test-template.js b/tests/specs/test-template.js
index b6651d2..69f487b 100644
--- a/tests/specs/test-template.js
+++ b/tests/specs/test-template.js
@@ -1,5 +1,5 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
/**
* Your test file should end with "-test.js" to be executed.
@@ -7,23 +7,25 @@
*/
describe('Test group description - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
/*
The slider that will be used for each test.
@@ -35,15 +37,12 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- });
-
- it('should be true', function() {
-
- });
- });
-}());
-
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ })
+
+ it('should be true', function() {})
+ })
+})()
diff --git a/tests/specs/ticks-test.js b/tests/specs/ticks-test.js
index b60db28..4379fd1 100644
--- a/tests/specs/ticks-test.js
+++ b/tests/specs/ticks-test.js
@@ -1,24 +1,26 @@
-(function() {
- "use strict";
+;(function() {
+ 'use strict'
describe('Ticks - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
it('should not create any tick if showTicks is false (default)', function() {
var sliderConf = {
@@ -26,12 +28,12 @@
options: {
floor: 0,
ceil: 100,
- step: 10
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(0);
- });
+ step: 10,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(0)
+ })
it('should create the correct number of ticks when showTicks is true', function() {
var sliderConf = {
@@ -40,12 +42,12 @@
floor: 0,
ceil: 100,
step: 10,
- showTicks: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(11);
- });
+ showTicks: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(11)
+ })
it('should create the correct number of ticks when showTicks is an integer', function() {
var sliderConf = {
@@ -54,12 +56,12 @@
floor: 0,
ceil: 100,
step: 10,
- showTicks: 20
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(6);
- });
+ showTicks: 20,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(6)
+ })
it('should create the correct number of ticks when showTicksValues is true', function() {
var sliderConf = {
@@ -68,36 +70,50 @@
floor: 0,
ceil: 100,
step: 10,
- showTicksValues: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(11);
- expect(helper.element[0].querySelectorAll('.rz-tick-value')).to.have.length(11);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.text()).to.equal('0');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.text()).to.equal('10');
- });
+ showTicksValues: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(11)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(11)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('0')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('10')
+ })
it('should create the correct number of ticks when showTicksValues is true and used with stepsArray', function() {
var sliderConf = {
value: 'C',
options: {
stepsArray: ['A', 'B', 'C', 'D', 'E'],
- showTicksValues: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(5);
- expect(helper.element[0].querySelectorAll('.rz-tick-value')).to.have.length(5);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.text()).to.equal('A');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.text()).to.equal('B');
- var lasTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[4]);
- expect(lasTick.text()).to.equal('E');
- });
+ showTicksValues: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(5)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(5)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('A')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('B')
+ var lasTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[4]
+ )
+ expect(lasTick.text()).to.equal('E')
+ })
it('should create the correct number of ticks when showTicksValues is true and used with stepsArray and bindIndexForStepsArray is true', function() {
var sliderConf = {
@@ -105,19 +121,27 @@
options: {
stepsArray: ['A', 'B', 'C', 'D', 'E'],
bindIndexForStepsArray: true,
- showTicksValues: true
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(5);
- expect(helper.element[0].querySelectorAll('.rz-tick-value')).to.have.length(5);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.text()).to.equal('A');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.text()).to.equal('B');
- var lasTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[4]);
- expect(lasTick.text()).to.equal('E');
- });
+ showTicksValues: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(5)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(5)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('A')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('B')
+ var lasTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[4]
+ )
+ expect(lasTick.text()).to.equal('E')
+ })
it('should create the correct number of ticks when showTicksValues is an integer', function() {
var sliderConf = {
@@ -126,20 +150,151 @@
floor: 0,
ceil: 100,
step: 10,
- showTicksValues: 20
+ showTicksValues: 20,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.ticks.hasClass('rz-ticks-values-under')).to.be.true
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(6)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(6)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('0')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('20')
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[5]
+ )
+ expect(lastTick.text()).to.equal('100')
+ })
+
+ it(
+ 'should create the correct number of ticks/values when showTick and showTicksValues' +
+ ' are integers with different values',
+ function() {
+ var sliderConf = {
+ value: 50,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ showTicksValues: 20,
+ showTicks: 10,
+ },
}
- };
- helper.createSlider(sliderConf);
- expect(helper.slider.ticks.hasClass('rz-ticks-values-under')).to.be.true;
- expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(6);
- expect(helper.element[0].querySelectorAll('.rz-tick-value')).to.have.length(6);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.text()).to.equal('0');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.text()).to.equal('20');
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[5]);
- expect(lastTick.text()).to.equal('100');
- });
+ helper.createSlider(sliderConf)
+ expect(helper.slider.ticks.hasClass('rz-ticks-values-under')).to.be.true
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(
+ 11
+ )
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(6)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('0')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('20')
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[5]
+ )
+ expect(lastTick.text()).to.equal('100')
+ }
+ )
+
+ it('should create the correct number of ticks when ticksArray is used', function() {
+ var sliderConf = {
+ value: 50,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ ticksArray: [0, 25, 50, 100],
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.ticks.hasClass('rz-ticks-values-under')).to.be.false
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(4)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(0)
+ })
+
+ it('should create the correct number of ticks when ticksArray is used along with showTicksValues', function() {
+ var sliderConf = {
+ value: 50,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ ticksArray: [0, 25, 50, 100],
+ showTicksValues: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.slider.ticks.hasClass('rz-ticks-values-under')).to.be.true
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(4)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(4)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.text()).to.equal('0')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.text()).to.equal('25')
+ var thirdTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[2]
+ )
+ expect(thirdTick.text()).to.equal('50')
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[3]
+ )
+ expect(lastTick.text()).to.equal('100')
+ })
+
+ it('should create the correct number of ticks when ticksArray is used as array of objects', function() {
+ var sliderConf = {
+ value: 50,
+ options: {
+ floor: 0,
+ ceil: 100,
+ step: 10,
+ ticksArray: [
+ { value: 0, legend: 'Bad' },
+ { value: 50, legend: 'Average' },
+ { value: 100, legend: 'Excellent' },
+ ],
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(3)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-value')
+ ).to.have.length(0)
+
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-legend')
+ ).to.have.length(3)
+ var firstLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[0]
+ )
+ expect(firstLegend.text()).to.equal('Bad')
+ var lastLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[2]
+ )
+ expect(lastLegend.text()).to.equal('Excellent')
+ })
it('should create the correct number of legend items when getLegend is defined', function() {
var sliderConf = {
@@ -150,17 +305,23 @@
step: 10,
showTicks: true,
getLegend: function(value) {
- return 'Legend for ' + value;
- }
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick-legend')).to.have.length(11);
- var firstLegend = angular.element(helper.element[0].querySelectorAll('.rz-tick-legend')[0]);
- expect(firstLegend.text()).to.equal('Legend for 0');
- var lastLegend = angular.element(helper.element[0].querySelectorAll('.rz-tick-legend')[10]);
- expect(lastLegend.text()).to.equal('Legend for 100');
- });
+ return 'Legend for ' + value
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-legend')
+ ).to.have.length(11)
+ var firstLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[0]
+ )
+ expect(firstLegend.text()).to.equal('Legend for 0')
+ var lastLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[10]
+ )
+ expect(lastLegend.text()).to.equal('Legend for 100')
+ })
it('should create the correct number of legend items when getLegend is defined and only some legend are displayed', function() {
var sliderConf = {
@@ -171,19 +332,24 @@
step: 10,
showTicks: true,
getLegend: function(value) {
- if(value % 20 === 0)
- return 'Legend for ' + value;
- return null;
- }
- }
- };
- helper.createSlider(sliderConf);
- expect(helper.element[0].querySelectorAll('.rz-tick-legend')).to.have.length(6);
- var firstLegend = angular.element(helper.element[0].querySelectorAll('.rz-tick-legend')[0]);
- expect(firstLegend.text()).to.equal('Legend for 0');
- var lastLegend = angular.element(helper.element[0].querySelectorAll('.rz-tick-legend')[5]);
- expect(lastLegend.text()).to.equal('Legend for 100');
- });
+ if (value % 20 === 0) return 'Legend for ' + value
+ return null
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ expect(
+ helper.element[0].querySelectorAll('.rz-tick-legend')
+ ).to.have.length(6)
+ var firstLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[0]
+ )
+ expect(firstLegend.text()).to.equal('Legend for 0')
+ var lastLegend = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-legend')[5]
+ )
+ expect(lastLegend.text()).to.equal('Legend for 100')
+ })
it('should set rz-selected class to ticks below the model value if showSelectionBar is true', function() {
var sliderConf = {
@@ -193,19 +359,27 @@
ceil: 100,
step: 10,
showTicks: true,
- showSelectionBar: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.true;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.false;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ showSelectionBar: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.true
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.false
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set rz-selected class to ticks above the model value if showSelectionBarEnd is true', function() {
var sliderConf = {
@@ -215,21 +389,31 @@
ceil: 100,
step: 10,
showTicks: true,
- showSelectionBarEnd: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.false;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.true;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.true;
- });
+ showSelectionBarEnd: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.false
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.true
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.true
+ })
it('should set rz-selected class to correct ticks if showSelectionBarFromValue is used and the model is on the right', function() {
var sliderConf = {
@@ -239,25 +423,39 @@
ceil: 100,
step: 10,
showTicks: true,
- showSelectionBarFromValue: 30
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var thirdTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[2]);
- expect(thirdTick.hasClass('rz-selected')).to.be.false;
- var fourthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[3]);
- expect(fourthTick.hasClass('rz-selected')).to.be.true;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.true;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.false;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ showSelectionBarFromValue: 30,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var thirdTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[2]
+ )
+ expect(thirdTick.hasClass('rz-selected')).to.be.false
+ var fourthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[3]
+ )
+ expect(fourthTick.hasClass('rz-selected')).to.be.true
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.true
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.false
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set rz-selected class to correct ticks if showSelectionBarFromValue is used and the model is on the left', function() {
var sliderConf = {
value: 50,
@@ -266,25 +464,39 @@
ceil: 100,
step: 10,
showTicks: true,
- showSelectionBarFromValue: 70
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.false;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.true;
- var eighthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[7]);
- expect(eighthTick.hasClass('rz-selected')).to.be.true;
- var ninthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[8]);
- expect(ninthTick.hasClass('rz-selected')).to.be.false;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ showSelectionBarFromValue: 70,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.false
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.true
+ var eighthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[7]
+ )
+ expect(eighthTick.hasClass('rz-selected')).to.be.true
+ var ninthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[8]
+ )
+ expect(ninthTick.hasClass('rz-selected')).to.be.false
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set rz-selected class to ticks between min/max if showSelectionBar is true on range slider', function() {
var sliderConf = {
@@ -294,19 +506,27 @@
floor: 0,
ceil: 100,
step: 10,
- showTicks: true
- }
- };
- helper.createRangeSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.true;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ showTicks: true,
+ },
+ }
+ helper.createRangeSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.true
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set the correct color to ticks when getSelectionBarColor is defined', function() {
var sliderConf = {
@@ -318,21 +538,21 @@
showTicks: true,
showSelectionBar: true,
getSelectionBarColor: function(value) {
- if (value <= 50)
- return 'red';
- else
- return 'green';
- }
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.css('background-color')).to.equal('red');
-
- helper.scope.slider.value = 100;
- helper.scope.$digest();
- expect(firstTick.css('background-color')).to.equal('green');
- });
+ if (value <= 50) return 'red'
+ else return 'green'
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.css('background-color')).to.equal('red')
+
+ helper.scope.slider.value = 100
+ helper.scope.$digest()
+ expect(firstTick.css('background-color')).to.equal('green')
+ })
it('should set correct tooltip attributes if ticksTooltip is defined for a horizontal slider', function() {
var sliderConf = {
@@ -343,17 +563,21 @@
step: 10,
showTicks: true,
ticksTooltip: function(value) {
- return 'tooltip for ' + value;
- }
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0');
- expect(firstTick.attr('tooltip-placement')).to.equal('top');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10');
- });
+ return 'tooltip for ' + value
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0')
+ expect(firstTick.attr('tooltip-placement')).to.equal('top')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10')
+ })
it('should set correct tooltip attributes if ticksTooltip is defined for a vertical slider', function() {
var sliderConf = {
@@ -365,17 +589,21 @@
vertical: true,
showTicks: true,
ticksTooltip: function(value) {
- return 'tooltip for ' + value;
- }
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0');
- expect(firstTick.attr('tooltip-placement')).to.equal('right');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10');
- });
+ return 'tooltip for ' + value
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0')
+ expect(firstTick.attr('tooltip-placement')).to.equal('right')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10')
+ })
it('should set correct tooltip attributes on rz-tick-value if ticksValuesTooltip is defined for a horizontal slider', function() {
var sliderConf = {
@@ -386,17 +614,21 @@
step: 10,
showTicksValues: true,
ticksValuesTooltip: function(value) {
- return 'tooltip for ' + value;
- }
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0');
- expect(firstTick.attr('tooltip-placement')).to.equal('top');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10');
- });
+ return 'tooltip for ' + value
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0')
+ expect(firstTick.attr('tooltip-placement')).to.equal('top')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10')
+ })
it('should set correct tooltip attributes on rz-tick-value if ticksValuesTooltip is defined for a vertical slider', function() {
var sliderConf = {
@@ -408,37 +640,43 @@
vertical: true,
showTicksValues: true,
ticksValuesTooltip: function(value) {
- return 'tooltip for ' + value;
- }
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0');
- expect(firstTick.attr('tooltip-placement')).to.equal('right');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10');
- });
- });
+ return 'tooltip for ' + value
+ },
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 0')
+ expect(firstTick.attr('tooltip-placement')).to.equal('right')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 10')
+ })
+ })
describe('Right to left Ticks - ', function() {
- var helper,
- RzSliderOptions,
- $rootScope,
- $timeout;
-
- beforeEach(module('test-helper'));
-
- beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
- helper = TestHelper;
- RzSliderOptions = _RzSliderOptions_;
- $rootScope = _$rootScope_;
- $timeout = _$timeout_;
- }));
+ var helper, RzSliderOptions, $rootScope, $timeout
+
+ beforeEach(module('test-helper'))
+
+ beforeEach(inject(function(
+ TestHelper,
+ _RzSliderOptions_,
+ _$rootScope_,
+ _$timeout_
+ ) {
+ helper = TestHelper
+ RzSliderOptions = _RzSliderOptions_
+ $rootScope = _$rootScope_
+ $timeout = _$timeout_
+ }))
afterEach(function() {
- helper.clean();
- });
+ helper.clean()
+ })
it('should set rz-selected class to ticks below the model value if showSelectionBar is true', function() {
var sliderConf = {
@@ -449,19 +687,27 @@
step: 10,
showTicks: true,
showSelectionBar: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.true;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.true;
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.true
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.true
+ })
it('should set rz-selected class to ticks above the model value if showSelectionBarEnd is true', function() {
var sliderConf = {
@@ -472,21 +718,31 @@
step: 10,
showTicks: true,
showSelectionBarEnd: true,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.true;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.true;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.false;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.true
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.true
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.false
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set rz-selected class to correct ticks if showSelectionBarFromValue is used and the model is on the right', function() {
var sliderConf = {
@@ -497,25 +753,39 @@
step: 10,
showTicks: true,
showSelectionBarFromValue: 30,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var thirdTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[2]);
- expect(thirdTick.hasClass('rz-selected')).to.be.false;
- var fourthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[3]);
- expect(fourthTick.hasClass('rz-selected')).to.be.false;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.false;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.true;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var thirdTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[2]
+ )
+ expect(thirdTick.hasClass('rz-selected')).to.be.false
+ var fourthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[3]
+ )
+ expect(fourthTick.hasClass('rz-selected')).to.be.false
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.false
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.true
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set rz-selected class to correct ticks if showSelectionBarFromValue is used and the model is on the left', function() {
var sliderConf = {
value: 50,
@@ -525,25 +795,39 @@
step: 10,
showTicks: true,
showSelectionBarFromValue: 70,
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.hasClass('rz-selected')).to.be.false;
- var fifthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[4]);
- expect(fifthTick.hasClass('rz-selected')).to.be.true;
- var sixthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[5]);
- expect(sixthTick.hasClass('rz-selected')).to.be.true;
- var seventhTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[6]);
- expect(seventhTick.hasClass('rz-selected')).to.be.false;
- var eighthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[7]);
- expect(eighthTick.hasClass('rz-selected')).to.be.false;
- var ninthTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[8]);
- expect(ninthTick.hasClass('rz-selected')).to.be.false;
- var lastTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[10]);
- expect(lastTick.hasClass('rz-selected')).to.be.false;
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.hasClass('rz-selected')).to.be.false
+ var fifthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[4]
+ )
+ expect(fifthTick.hasClass('rz-selected')).to.be.true
+ var sixthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[5]
+ )
+ expect(sixthTick.hasClass('rz-selected')).to.be.true
+ var seventhTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[6]
+ )
+ expect(seventhTick.hasClass('rz-selected')).to.be.false
+ var eighthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[7]
+ )
+ expect(eighthTick.hasClass('rz-selected')).to.be.false
+ var ninthTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[8]
+ )
+ expect(ninthTick.hasClass('rz-selected')).to.be.false
+ var lastTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[10]
+ )
+ expect(lastTick.hasClass('rz-selected')).to.be.false
+ })
it('should set the correct color to ticks when getSelectionBarColor is defined', function() {
var sliderConf = {
@@ -555,22 +839,22 @@
showTicks: true,
showSelectionBar: true,
getSelectionBarColor: function(value) {
- if (value <= 50)
- return 'red';
- else
- return 'green';
+ if (value <= 50) return 'red'
+ else return 'green'
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[9]);
- expect(firstTick.css('background-color')).to.equal('red');
-
- helper.scope.slider.value = 100;
- helper.scope.$digest();
- expect(firstTick.css('background-color')).to.equal('green');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[9]
+ )
+ expect(firstTick.css('background-color')).to.equal('red')
+
+ helper.scope.slider.value = 100
+ helper.scope.$digest()
+ expect(firstTick.css('background-color')).to.equal('green')
+ })
it('should set correct tooltip attributes if ticksTooltip is defined for a horizontal slider', function() {
var sliderConf = {
@@ -581,18 +865,22 @@
step: 10,
showTicks: true,
ticksTooltip: function(value) {
- return 'tooltip for ' + value;
+ return 'tooltip for ' + value
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100');
- expect(firstTick.attr('tooltip-placement')).to.equal('top');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100')
+ expect(firstTick.attr('tooltip-placement')).to.equal('top')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90')
+ })
it('should set correct tooltip attributes if ticksTooltip is defined for a vertical slider', function() {
var sliderConf = {
@@ -604,18 +892,22 @@
vertical: true,
showTicks: true,
ticksTooltip: function(value) {
- return 'tooltip for ' + value;
+ return 'tooltip for ' + value
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100');
- expect(firstTick.attr('tooltip-placement')).to.equal('right');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100')
+ expect(firstTick.attr('tooltip-placement')).to.equal('right')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90')
+ })
it('should set correct tooltip attributes on rz-tick-value if ticksValuesTooltip is defined for a horizontal slider', function() {
var sliderConf = {
@@ -626,18 +918,22 @@
step: 10,
showTicksValues: true,
ticksValuesTooltip: function(value) {
- return 'tooltip for ' + value;
+ return 'tooltip for ' + value
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100');
- expect(firstTick.attr('tooltip-placement')).to.equal('top');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90');
- });
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100')
+ expect(firstTick.attr('tooltip-placement')).to.equal('top')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90')
+ })
it('should set correct tooltip attributes on rz-tick-value if ticksValuesTooltip is defined for a vertical slider', function() {
var sliderConf = {
@@ -649,19 +945,21 @@
vertical: true,
showTicksValues: true,
ticksValuesTooltip: function(value) {
- return 'tooltip for ' + value;
+ return 'tooltip for ' + value
},
- rightToLeft: true
- }
- };
- helper.createSlider(sliderConf);
- var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
- expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100');
- expect(firstTick.attr('tooltip-placement')).to.equal('right');
- var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
- expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90');
- });
- });
-
-}());
-
+ rightToLeft: true,
+ },
+ }
+ helper.createSlider(sliderConf)
+ var firstTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[0]
+ )
+ expect(firstTick.attr('uib-tooltip')).to.equal('tooltip for 100')
+ expect(firstTick.attr('tooltip-placement')).to.equal('right')
+ var secondTick = angular.element(
+ helper.element[0].querySelectorAll('.rz-tick-value')[1]
+ )
+ expect(secondTick.attr('uib-tooltip')).to.equal('tooltip for 90')
+ })
+ })
+})()