Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / 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                 deepEqual( $("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                 deepEqual( textValueButton.siblings().text(), "foo" );
21
22                 // use the text where it's provided
23                 deepEqual( textValueButton.siblings().text(), "foo" );
24                 textValueButton.text( "bar" ).button( 'refresh' );
25                 deepEqual( textValueButton.siblings().text(), "bar" );
26
27                 // use the val if it's provided where the text isn't
28                 deepEqual( valueButton.siblings().text(), "foo" );
29                 valueButton.val( "bar" ).button( 'refresh' );
30                 deepEqual( valueButton.siblings().text(), "bar" );
31
32                 // prefer the text to the value
33                 textValueButton.text( "bar" ).val( "baz" ).button( 'refresh' );
34                 deepEqual( 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                         deepEqual( $form.find( "input[type='hidden']" ).length, 1, "hidden form input should be added" );
45
46                         $form.trigger( "submit" );
47                         deepEqual( $form.find( "[type='hidden']" ).length, 0, "hidden form input is removed" );
48                 }
49         });
50
51         test( "theme should be inherited", function() {
52                 var $inherited = $( "#theme-check" ),
53                     $explicit = $( "#theme-check-explicit" );
54
55                 ok( $inherited.closest("div").hasClass( "ui-btn-up-a" ), "should inherit from page" );
56                 ok( $explicit.closest("div").hasClass( "ui-btn-up-b" ), "should not inherit" );
57         });
58
59         test( "Enhanced button elements should allow for phrasing content.", function() {
60                 var $htmlstring = $( "#contains-html" ),
61                     $htmlval = $( "#val-contains-html" );
62
63                 ok( $htmlstring.parent().find(".ui-btn-text").find("sup").length, "HTML contained within a button element should carry over to the enhanced version" );
64                 ok( $htmlval.parent().find(".ui-btn-text").text().length > 1, "If the text is pulled from a button’s value, anything HTML-like should be disregarded." );
65         });
66
67 })( jQuery );