diff options
author | David Petersen <public@petersendidit.com> | 2013-01-30 13:07:33 -0600 |
---|---|---|
committer | David Petersen <public@petersendidit.com> | 2013-02-05 08:31:42 -0600 |
commit | df077abfc2a236a373d2080a9ceae97bb48c2620 (patch) | |
tree | a14e1b5042ef68355af4e54d88fdd918236026ea /tests/unit/slider/slider_options.js | |
parent | b440979ba6f0b6299dc2cb9c60939d1b7998fd5e (diff) | |
download | jquery-ui-df077abfc2a236a373d2080a9ceae97bb48c2620.tar.gz jquery-ui-df077abfc2a236a373d2080a9ceae97bb48c2620.zip |
Slider: allow range option to be changed. Fixed #5602 - Slider Does Not Exhibit Proper Behavior When Switching Range
Diffstat (limited to 'tests/unit/slider/slider_options.js')
-rw-r--r-- | tests/unit/slider/slider_options.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index a7bd3ae83..dd213d03b 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -203,4 +203,107 @@ test("values", function() { ); }); +test( "range", function() { + expect( 27 ); + var element, range; + + // min + element = $("<div></div>").slider({ + range: "min", + min: 1, + max: 10, + step: 1 + }); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range min, one handle"); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range min" ); + element.slider( "destroy" ); + + // max + element = $("<div></div>").slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range max, one handle"); + equal( element.find( ".ui-slider-range-max" ).length, 1, "range max" ); + element.slider( "destroy" ); + + // true + element = $("<div></div>").slider({ + range: true, + min: 1, + max: 10, + step: 1 + }); + + range = element.find( ".ui-slider-range" ); + equal( element.find( ".ui-slider-handle" ).length, 2, "range true, two handles"); + ok( !range.is( ".ui-slider-range-min"), "range true" ); + ok( !range.is( ".ui-slider-range-max"), "range true" ); + element.slider( "destroy" ); + + // Change range from min to max + element = $("<div></div>").slider({ + range: "min", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "max" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from min to max, one handle"); + equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from min to max" ); + equal( element.find( ".ui-slider-range-max" ).length, 1, "range switch from min to max" ); + element.slider( "destroy" ); + + // Change range from max to min + element = $("<div></div>").slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "min" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from max to min, one handle"); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to min" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from max to min" ); + element.slider( "destroy" ); + + // Change range from max to true + element = $("<div></div>").slider({ + range: "max", + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", true ); + + equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from max to true, two handles"); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from max to true" ); + equal( element.find( ".ui-slider-range-min" ).length, 0, "range switch from max to true" ); + equal( element.slider( "option", "value" ), 0 , "option value" ); + equal( element.slider( "value" ), 1 , "value" ); + deepEqual( element.slider( "option", "values" ), [1, 1], "option values" ); + deepEqual( element.slider( "values" ), [1, 1], "values" ); + element.slider( "destroy" ); + + // Change range from true to min + element = $("<div></div>").slider({ + range: true, + min: 1, + max: 10, + step: 1 + }).slider( "option", "range", "min" ); + + equal( element.find( ".ui-slider-handle" ).length, 1, "range switch from true to min, one handle"); + equal( element.find( ".ui-slider-range-max" ).length, 0, "range switch from true to min" ); + equal( element.find( ".ui-slider-range-min" ).length, 1, "range switch from true to min" ); + equal( element.slider( "option", "value" ), 1, "value" ); + equal( element.slider( "value" ), 1 , "value" ); + equal( element.slider( "option", "values" ), null, "values" ); + deepEqual( element.slider( "values" ), [] , "values" ); + element.slider( "destroy" ); +}); + })(jQuery); |