2 * mobile button unit tests
5 $.mobile.page.prototype.options.keepNative = "button.should-be-native";
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 );
11 test( "button elements should be enhanced", function() {
12 ok( $("#enhanced").hasClass( "ui-btn-hidden" ) );
15 test( "button markup text value should be changed on refresh", function() {
16 var textValueButton = $("#text"), valueButton = $("#value");
18 // the value shouldn't change unless it's been altered
19 textValueButton.button( 'refresh' );
20 deepEqual( textValueButton.siblings().text(), "foo" );
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" );
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" );
32 // prefer the text to the value
33 textValueButton.text( "bar" ).val( "baz" ).button( 'refresh' );
34 deepEqual( textValueButton.siblings().text(), "bar" );
38 test( "verify the button placeholder is added many times", function() {
39 var $form = $( "#hidden-element-addition-form" ), count = 3;
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" );
46 $form.trigger( "submit" );
47 deepEqual( $form.find( "[type='hidden']" ).length, 0, "hidden form input is removed" );
51 test( "theme should be inherited", function() {
52 var $inherited = $( "#theme-check" ),
53 $explicit = $( "#theme-check-explicit" );
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" );
59 test( "Enhanced button elements should allow for phrasing content.", function() {
60 var $htmlstring = $( "#contains-html" ),
61 $htmlval = $( "#val-contains-html" );
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." );