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
/*
******************
Focus Option Tests
******************
This spec has tests for checking proper behavior of the focus option.
*/
describe("Focus Option Tests", function() {
var testSlider;
var simulateMousedown = function(target, pos) {
var myEvent = document.createEvent("MouseEvents");
myEvent.initEvent("mousedown", true, true);
myEvent.pageX = pos;
myEvent.pageY = pos;
target.dispatchEvent(myEvent);
};
it("handle should not be focused after value change when 'focus' is false", function() {
testSlider = $("#testSlider1").slider({
min : 0,
max : 10,
value: 0,
focus: false,
id : "testSlider"
});
var hasFocus;
$("#testSlider").find(".min-slider-handle").focus(function() {
hasFocus = true;
});
simulateMousedown($("#testSlider").find(".slider-track-high").get(0), 1000);
expect(hasFocus).toBe(undefined);
});
it("handle should be focused after value change when 'focus' is true", function() {
testSlider = $("#testSlider1").slider({
min : 0,
max : 10,
value: 0,
focus: true,
id : "testSlider"
});
var hasFocus;
$("#testSlider").find(".min-slider-handle").focus(function() {
hasFocus = true;
});
simulateMousedown($("#testSlider").find(".slider-track-high").get(0), 1000);
expect(hasFocus).toBe(true);
});
afterEach(function() {
if (testSlider) {
testSlider.slider("destroy");
testSlider = null;
}
});
});