diff options
author | Richard Worth <rdworth@gmail.com> | 2009-02-02 05:58:49 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2009-02-02 05:58:49 +0000 |
commit | c3046b9d798b406803beaf83dc42e0171672fe89 (patch) | |
tree | ffed61959b0219b836d6247c3689777c22474f16 /tests/unit/slider/slider_options.js | |
parent | 8735354b1009a4c254b661f14f87dc196859608e (diff) | |
download | jquery-ui-c3046b9d798b406803beaf83dc42e0171672fe89.tar.gz jquery-ui-c3046b9d798b406803beaf83dc42e0171672fe89.zip |
slider unit tests: created separate file for each module: core, common widget, events, methods, options, tickets
Diffstat (limited to 'tests/unit/slider/slider_options.js')
-rw-r--r-- | tests/unit/slider/slider_options.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js new file mode 100644 index 000000000..cc624a0e3 --- /dev/null +++ b/tests/unit/slider/slider_options.js @@ -0,0 +1,105 @@ +/* + * slider_options.js + */ +(function($) { + +function handle() { + return el.find(".ui-slider-handle"); +} + +module("slider: options"); + +test("animate", function() { + ok(false, "missing test - untested code is broken code."); +}); + +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."); +}); + +test("step", function() { + ok(false, "missing test - untested code is broken code."); +}); + +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); |