a1104f0f5c81f3a583aaeab17f77f33f76d6d081
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / tests / unit / button / button_core.js
1 /*
2  * mobile button unit tests
3  */
4 (function($){
5         $.mobile.page.prototype.options.keepNative = "button.should-be-native";
6
7         test( "button elements in the keepNative set shouldn't be enhanced", function() {
8                 same( $("button.should-be-native").siblings("div.ui-slider").length, 0 );
9         });
10
11         test( "button elements should be enhanced", function() {
12                 ok( $("#enhanced").hasClass( "ui-btn-hidden" ) );
13         });
14
15         test( "button markup text value should be changed on refresh", function() {
16                 var textValueButton = $("#text"), valueButton = $("#value");
17
18                 // the value shouldn't change unless it's been altered
19                 textValueButton.button( 'refresh' );
20                 same( textValueButton.siblings().text(), "foo" );
21
22                 // use the text where it's provided
23                 same( textValueButton.siblings().text(), "foo" );
24                 textValueButton.text( "bar" ).button( 'refresh' );
25                 same( textValueButton.siblings().text(), "bar" );
26
27                 // use the val if it's provided where the text isn't
28                 same( valueButton.siblings().text(), "foo" );
29                 valueButton.val( "bar" ).button( 'refresh' );
30                 same( valueButton.siblings().text(), "bar" );
31
32                 // prefer the text to the value
33                 textValueButton.text( "bar" ).val( "baz" ).button( 'refresh' );
34                 same( textValueButton.siblings().text(), "bar" );
35         });
36
37         // Issue 2877
38         test( "verify the button placeholder is added many times", function() {
39                 var $form =     $( "#hidden-element-addition-form" ), count = 3;
40                 expect( count * 2 );
41
42                 for( var x = 0; x < count; x++ ) {
43                         $( "#hidden-element-addition" ).trigger( "vclick" );
44                         same( $form.find( "input[type='hidden']" ).length, 1, "hidden form input should be added" );
45
46                         $form.trigger( "submit" );
47                         same( $form.find( "[type='hidden']" ).length, 0, "hidden form input is removed" );
48                 }
49         });
50 })( jQuery );