2 * mobile slider unit tests
5 $.mobile.page.prototype.options.keepNative = "input.should-be-native";
7 // not testing the positive case here since's it's obviously tested elsewhere
8 test( "slider elements in the keepNative set shouldn't be enhanced", function() {
9 same( $("input.should-be-native").siblings("div.ui-slider").length, 0 );
12 test( "refresh should force val to nearest step", function() {
13 var slider = $( "#step-slider" ),
14 step = parseInt(slider.attr( "step" ), 10);
16 slider.val( step + 1 );
18 slider.slider( 'refresh' );
20 ok( step > 1, "the step is greater than one" );
21 ok( slider.val() > 0, "the value has been altered" );
22 same( slider.val() % step, 0, "value has 'snapped' to a step" );
25 test( "empty string value results defaults to slider min value", function() {
26 var slider = $( "#empty-string-val-slider" );
27 same( slider.attr('min'), "10", "slider min is greater than 0" );
28 same( slider.val( '' ).slider( 'refresh' ).val(), slider.attr('min'), "val is equal to min attr");
31 test( "flip toggle switch title should be current selected value attr", function() {
32 var slider = $( "#slider-switch" );
34 same(slider.siblings(".ui-slider").find("a").attr('title'),
35 $(slider.find("option")[slider[0].selectedIndex]).text(),
36 "verify that the link title is set to the selected option text");
39 test( "data-highlight works properly", function() {
40 var $highlighted = $("#background-slider"), $unhighlighted = $("#no-background-slider");
42 same( $highlighted.siblings( ".ui-slider" ).find( ".ui-slider-bg" ).length, 1,
43 "highlighted slider should have a div for the track bg" );
44 same( $unhighlighted.siblings( ".ui-slider" ).find( ".ui-slider-bg" ).length, 0,
45 "unhighlighted slider _not_ should have a div for the track bg" );