summaryrefslogtreecommitdiff
path: root/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
committerLeif Johansson <leifj@sunet.se>2011-11-25 21:18:19 +0100
commit3909e6d89e01e4cd8777377c63037896bb95aa2f (patch)
tree59679df287c2bee55087fb5afb8d42e7f93a44fb /src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js
parente5f94e9be5017f627c1ccd8c6306c5cc2e200432 (diff)
new jq layout
Diffstat (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js')
-rw-r--r--src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js
new file mode 100644
index 0000000..040589b
--- /dev/null
+++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_options.js
@@ -0,0 +1,146 @@
+/*
+ * slider_options.js
+ */
+(function($) {
+
+var el, options;
+
+function handle() {
+ return el.find(".ui-slider-handle");
+}
+
+module("slider: options");
+
+test("max", function() {
+ el = $('<div></div>');
+
+ options = {
+ max: 37,
+ min: 6,
+ orientation: 'horizontal',
+ step: 1,
+ value: 50
+ };
+
+ el.slider(options);
+ ok(el.slider("option", "value") == options.value, "value option is not contained by max");
+ ok(el.slider("value") == options.max, "value method is contained by max");
+ el.slider('destroy');
+
+});
+
+test("min", function() {
+ el = $('<div></div>');
+
+ options = {
+ max: 37,
+ min: 6,
+ orientation: 'vertical',
+ step: 1,
+ value: 2
+ };
+
+ el.slider(options);
+ ok(el.slider("option", "value") == options.value, "value option is not contained by min");
+ ok(el.slider("value") == options.min, "value method is contained by min");
+ el.slider('destroy');
+
+});
+
+test("orientation", function() {
+ el = $('<div></div>');
+
+ options = {
+ max: 2,
+ min: -2,
+ orientation: 'vertical',
+ value: 1
+ };
+
+ var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
+
+ el.slider(options).slider("option", "orientation", "horizontal");
+ ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal");
+ ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical");
+ equals(handle().css('left'), percentVal + '%', "horizontal slider handle is positioned with left: %");
+
+ el.slider('destroy');
+
+ options = {
+ max: 2,
+ min: -2,
+ orientation: 'horizontal',
+ value: -1
+ };
+
+ var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
+
+ el.slider(options).slider("option", "orientation", "vertical");
+ ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
+ ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal");
+ equals(handle().css('bottom'), percentVal + '%', "vertical slider handle is positioned with bottom: %");
+
+ el.slider('destroy');
+
+});
+
+//test("range", function() {
+// ok(false, "missing test - untested code is broken code.");
+//});
+
+//spec: http://wiki.jqueryui.com/Slider#specs
+// value option/method: the value option is not restricted by min/max/step.
+// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
+test("step", function() {
+ var el = $('<div></div>').slider({
+ min: 0,
+ value: 0,
+ step: 10,
+ max: 100
+ });
+ equals( el.slider("value"), 0 );
+
+ el.slider("value", 1);
+ equals( el.slider("value"), 0 );
+
+ el.slider("value", 9);
+ equals( el.slider("value"), 10 );
+
+ el.slider("value", 11);
+ equals( el.slider("value"), 10 );
+
+ el.slider("value", 19);
+ equals( el.slider("value"), 20 );
+
+el = $('<div></div>').slider({
+ min: 0,
+ value: 0,
+ step: 20,
+ max: 100
+ });
+ el.slider("value", 0);
+
+ el.slider("option", "value", 1);
+ equals( el.slider("value"), 0 );
+
+ el.slider("option", "value", 9);
+ equals( el.slider("value"), 0 );
+
+ el.slider("option", "value", 11);
+ equals( el.slider("value"), 20 );
+
+ el.slider("option", "value", 19);
+ equals( el.slider("value"), 20 );
+
+ el.slider('destroy');
+});
+
+//test("value", function() {
+// ok(false, "missing test - untested code is broken code.");
+//});
+
+//test("values", function() {
+// ok(false, "missing test - untested code is broken code.");
+//});
+
+})(jQuery);