forked from leongersen/noUiSlider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider_setting-getting.js
64 lines (45 loc) · 1.99 KB
/
slider_setting-getting.js
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
QUnit.test("Value setting/getting", function (assert) {
document.getElementById('qunit-fixture').innerHTML = '<div class="slider"></div>';
var slider = document.getElementById('qunit-fixture').querySelector('.slider');
noUiSlider.create(slider, {
range: {min: -30, max: 1080},
start: [0, 10],
behaviour: 'drag',
connect: true,
format: {
to: function (x) {
return x.toFixed(1);
},
from: Number
}
});
assert.deepEqual(slider.noUiSlider.get(), ["0.0", "10.0"]);
slider.noUiSlider.set([-10, 80]);
assert.deepEqual(slider.noUiSlider.get(), ["-10.0", "80.0"]);
slider.noUiSlider.set(5);
assert.deepEqual(slider.noUiSlider.get(), ["5.0", "80.0"]);
slider.noUiSlider.set([10, 980.51]);
assert.deepEqual(slider.noUiSlider.get(), ["10.0", "980.5"]);
slider.noUiSlider.set([null]);
assert.deepEqual(slider.noUiSlider.get(), ["10.0", "980.5"]);
slider.noUiSlider.set([null, 80]);
assert.deepEqual(slider.noUiSlider.get(), ["10.0", "80.0"]);
slider.noUiSlider.set([10.6]);
assert.deepEqual(slider.noUiSlider.get(), ["10.6", "80.0"]);
slider.noUiSlider.set([null, 10.6]);
assert.deepEqual(slider.noUiSlider.get(), ["10.6", "10.6"]);
slider.noUiSlider.set([30, null]);
assert.deepEqual(slider.noUiSlider.get(), ["30.0", "30.0"]);
slider.noUiSlider.set(null);
assert.deepEqual(slider.noUiSlider.get(), ["30.0", "30.0"]);
slider.noUiSlider.set(false);
assert.deepEqual(slider.noUiSlider.get(), ["30.0", "30.0"]);
slider.noUiSlider.setHandle(0, 20);
assert.deepEqual(slider.noUiSlider.get(), ["20.0", "30.0"]);
slider.noUiSlider.setHandle(1, 40);
assert.deepEqual(slider.noUiSlider.get(), ["20.0", "40.0"]);
slider.noUiSlider.setHandle(1, 15);
assert.deepEqual(slider.noUiSlider.get(), ["20.0", "20.0"]);
slider.noUiSlider.setHandle(1, null);
assert.deepEqual(slider.noUiSlider.get(), ["20.0", "20.0"]);
});