Skip to content

Commit 9897126

Browse files
committed
Add tests to the gradient feature
1 parent 5808e4c commit 9897126

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

demo/demo.js

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $uibModal) {
9999
minValue: 0,
100100
maxValue: 33,
101101
options: {
102+
ceil: 100,
102103
showSelectionBar: true,
103104
selectionBarGradient: {
104105
from: 'white',

tests/specs/options-handling-test.js

+43
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,49 @@
413413
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
414414
});
415415

416+
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() {
417+
var sliderConf = {
418+
min: 5,
419+
max: 10,
420+
options: {
421+
floor: 0,
422+
ceil: 20,
423+
selectionBarGradient: {
424+
from: 'white',
425+
to: 'blue'
426+
}
427+
}
428+
};
429+
430+
helper.createRangeSlider(sliderConf);
431+
432+
var expectedPosition = -(Math.round(helper.slider.valueToPosition(5)) + helper.slider.handleHalfDim) + 'px center',
433+
actualPosition = helper.slider.scope.barStyle.backgroundPosition;
434+
expect(actualPosition).to.equal(expectedPosition);
435+
});
436+
437+
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() {
438+
var sliderConf = {
439+
value: 5,
440+
options: {
441+
floor: 0,
442+
ceil: 20,
443+
vertical: true,
444+
showSelectionBar: true,
445+
selectionBarGradient: {
446+
from: 'white',
447+
to: 'blue'
448+
}
449+
}
450+
};
451+
452+
helper.createSlider(sliderConf);
453+
454+
var expectedGradient = 'linear-gradient(to top, white 0%,blue 100%)',
455+
actualGradient = helper.slider.scope.barStyle.backgroundImage;
456+
expect(actualGradient).to.equal(expectedGradient);
457+
});
458+
416459
it('should set alwaysHide on floor/ceil when hideLimitLabels is set to true', function() {
417460
var sliderConf = {
418461
value: 10,

0 commit comments

Comments
 (0)