From 3909e6d89e01e4cd8777377c63037896bb95aa2f Mon Sep 17 00:00:00 2001 From: Leif Johansson Date: Fri, 25 Nov 2011 21:18:19 +0100 Subject: new jq layout --- .../tests/unit/slider/slider_methods.js | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_methods.js (limited to 'src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_methods.js') diff --git a/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_methods.js b/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_methods.js new file mode 100644 index 0000000..66624e8 --- /dev/null +++ b/src/main/webapp/jquery-ui-1.9pre/tests/unit/slider/slider_methods.js @@ -0,0 +1,102 @@ +/* + * slider_methods.js + */ +(function($) { + +module("slider: methods"); + +test("init", function() { + expect(5); + + $("
").appendTo('body').slider().remove(); + ok(true, '.slider() called on element'); + + $([]).slider().remove(); + ok(true, '.slider() called on empty collection'); + + $('
').slider().remove(); + ok(true, '.slider() called on disconnected DOMElement'); + + var el = $('
').slider(); + var foo = el.slider("option", "foo"); + el.remove(); + ok(true, 'arbitrary option getter after init'); + + $('
').slider().slider("option", "foo", "bar").remove(); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + $("
").appendTo('body').slider().slider("destroy").remove(); + ok(true, '.slider("destroy") called on element'); + + $([]).slider().slider("destroy").remove(); + ok(true, '.slider("destroy") called on empty collection'); + + $('
').appendTo('body').remove().slider().slider("destroy").remove(); + ok(true, '.slider("destroy") called on disconnected DOMElement'); + + var expected = $('
').slider(), + actual = expected.slider('destroy'); + equals(actual, expected, 'destroy is chainable'); +}); + +test("enable", function() { + var expected = $('
').slider(), + actual = expected.slider('enable'); + equals(actual, expected, 'enable is chainable'); + + var el = $('
').slider({ disabled: true }); + ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class before enable method call'); + ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call'); + el.slider('enable'); + ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class after enable method call'); + ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class after enable method call'); +}); + +test("disable", function() { + var expected = $('
').slider(), + actual = expected.slider('disable'); + equals(actual, expected, 'disable is chainable'); + + var el = $('
').slider({ disabled: false }); + ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class before disabled method call'); + ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call'); + el.slider('disable'); + ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class after disable method call'); + ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class after disable method call'); +}); + +test("value", function() { + $([false, 'min', 'max']).each(function() { + var el = $('
').slider({ + range: this, + value: 5 + }); + equals(el.slider('value'), 5, 'range: ' + this + ' slider method get'); + equals(el.slider('value', 10), el, 'value method is chainable'); + equals(el.slider('value'), 10, 'range: ' + this + ' slider method set'); + el.remove(); + }); + var el = $('
').slider({ + min: -1, value: 0, max: 1 + }); + // min with value option vs value method + el.slider('option', 'value', -2); + equals(el.slider('option', 'value'), -2, 'value option does not respect min'); + equals(el.slider('value'), -1, 'value method get respects min'); + equals(el.slider('value', -2), el, 'value method is chainable'); + equals(el.slider('option', 'value'), -1, 'value method set respects min'); + // max with value option vs value method + el.slider('option', 'value', 2); + equals(el.slider('option', 'value'), 2, 'value option does not respect max'); + equals(el.slider('value'), 1, 'value method get respects max'); + equals(el.slider('value', 2), el, 'value method is chainable'); + equals(el.slider('option', 'value'), 1, 'value method set respects max'); +}); + +//test("values", function() { +// ok(false, "missing test - untested code is broken code."); +//}); + +})(jQuery); -- cgit v1.1