Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
*************************
Logarithmic Scale Tests
*************************
*/
describe("Slider with logarithmic scale tests", function() {
var testSlider;
it("Should properly position the slider", function() {
testSlider = $("#testSlider1").slider({
min: 0,
max: 10000,
scale: 'logarithmic',
value: 100 // This should be at 50%
});
var expectedPostition = 210 / 2 + 'px';
var handle = $("#testSlider1").siblings('div.slider').find('.min-slider-handle');
expect(handle.css('left')).toBe(expectedPostition);
});
it("Should properly position the tick marks", function() {
testSlider = $("#testSlider1").slider({
min: 0,
max: 100,
scale: 'logarithmic',
ticks: [0,10,20,50,100]
});
// Position expected for the '10' tick
var expectedTickOnePosition = 210 / 2 + 'px'; //should be at 50%
var handle = $("#testSlider1").siblings('div.slider').find(".slider-tick").eq(1);
expect(handle.css('left')).toBe(expectedTickOnePosition);
});
it("Should use step size when navigating the keyboard", function() {
testSlider = $("#testSlider1").slider({
min: 0,
max: 10000,
scale: 'logarithmic',
value: 100,
step: 5
});
// Focus on handle1
var handle1 = $("#testSlider1").siblings('div.slider:first').find('.slider-handle');
handle1.focus();
// Create keyboard event
var keyboardEvent = document.createEvent("Events");
keyboardEvent.initEvent("keydown", true, true);
var keyPresses = 0;
handle1.on("keydown", function() {
keyPresses++;
var value = $("#testSlider1").slider('getValue');
expect(value).toBe(100 + keyPresses*5);
});
keyboardEvent.keyCode = keyboardEvent.which = 39; // RIGHT
for (var i = 0; i < 5; i++) {
handle1[0].dispatchEvent(keyboardEvent);
}
});
afterEach(function() {
if(testSlider) {
testSlider.slider('destroy');
testSlider = null;
}
});
});