diff options
author | Richard Worth <rdworth@gmail.com> | 2008-11-12 02:52:31 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2008-11-12 02:52:31 +0000 |
commit | e47820f6ea7810569684464c3a3b02eda5d9604d (patch) | |
tree | adb2aba03fe9d7736ac72118b754101e696f37fa /tests/slider.js | |
parent | 7d946ec774e7fd832c0c691076338eae69e9b894 (diff) | |
download | jquery-ui-e47820f6ea7810569684464c3a3b02eda5d9604d.tar.gz jquery-ui-e47820f6ea7810569684464c3a3b02eda5d9604d.zip |
tests: cleanup and consistency with defaults tests
Diffstat (limited to 'tests/slider.js')
-rw-r--r-- | tests/slider.js | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/tests/slider.js b/tests/slider.js index b13acc4a9..3fbdd8b74 100644 --- a/tests/slider.js +++ b/tests/slider.js @@ -2,6 +2,23 @@ * slider unit tests */ (function($) { +// +// Selectable Test Helper Functions +// + +var defaults = { + animate: false, + axis: "???", + handle: ".ui-slider-handle", + handles: "???", + disabled: false, + max: 100, + min: 0, + range: false, + startValue: "???", + stepping: "???", + steps: 0 +}; var keyCodes = { leftArrow: 37, @@ -32,7 +49,67 @@ function assertChange(stepping, start, result, action) { } } -module("slider: single handle") +// Slider Tests +module("slider"); + +test("init", function() { + expect(6); + + $("<div></div>").appendTo('body').slider().remove(); + ok(true, '.slider() called on element'); + + $([]).slider().remove(); + ok(true, '.slider() called on empty collection'); + + $('<div></div>').slider().remove(); + ok(true, '.slider() called on disconnected DOMElement'); + + $('<div></div>').slider().slider("foo").remove(); + ok(true, 'arbitrary method called after init'); + + el = $('<div></div>').slider(); + var foo = el.data("foo.slider"); + el.remove(); + ok(true, 'arbitrary option getter after init'); + + $('<div></div>').slider().data("foo.slider", "bar").remove(); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + expect(6); + + $("<div></div>").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'); + + $('<div></div>').slider().slider("destroy").remove(); + ok(true, '.slider("destroy") called on disconnected DOMElement'); + + $('<div></div>').slider().slider("destroy").slider("foo").remove(); + ok(true, 'arbitrary method called after destroy'); + + el = $('<div></div>').slider(); + var foo = el.slider("destroy").data("foo.slider"); + el.remove(); + ok(true, 'arbitrary option getter after destroy'); + + $('<div></div>').slider().slider("destroy").data("foo.slider", "bar").remove(); + ok(true, 'arbitrary option setter after destroy'); +}); + +test("defaults", function() { + el = $('<div></div>').slider(); + $.each(defaults, function(key, val) { + var actual = el.data(key + ".slider"), expected = val; + same(actual, expected, key); + }); + el.remove(); +}); + +module("slider: single handle"); test("change one step via keydown", assertChange(1, undefined, 1, function() { this.find("a").rightArrow(); |