Tokentextarea: Fix issues
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / tests / unit / slider / slider_core.js
1 /*
2  * mobile slider unit tests
3  */
4 (function($){
5         $.mobile.page.prototype.options.keepNative = "input.should-be-native";
6
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 );
10         });
11
12         test( "refresh should force val to nearest step", function() {
13                 var slider = $( "#step-slider" ),
14                         step = parseInt(slider.attr( "step" ), 10);
15
16                 slider.val( step + 1 );
17
18                 slider.slider( 'refresh' );
19
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" );
23         });
24
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");
29         });
30
31         test( "flip toggle switch title should be current selected value attr", function() {
32                 var slider = $( "#slider-switch" );
33
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");
37         });
38
39         test( "data-highlight works properly", function() {
40                 var $highlighted = $("#background-slider"), $unhighlighted = $("#no-background-slider");
41
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" );
46         });
47 })( jQuery );