2 * mobile buttonMarkup tests
5 module("jquery.mobile.buttonMarkup.js");
7 test( "header buttons should have the header class", function() {
8 var headerButton1 = $("#header-button-1"),
9 headerButton2 = $("#header-button-2");
11 ok((headerButton1.hasClass("ui-btn-left") &&
12 headerButton2.hasClass("ui-btn-right")), "first header button should have class 'ui-btn-left' and the second one should have 'ui-btn-right'");
15 test( "control group buttons should be enhanced inside a footer", function(){
18 group = $("#control-group-footer");
19 linkCount = group.find( "a" ).length;
21 same( group.find("a.ui-btn").length, linkCount, "all 4 links should be buttons");
22 same( group.find("a > span.ui-corner-left").length, 1, "only 1 left cornered button");
23 same( group.find("a > span.ui-corner-right").length, 1, "only 1 right cornered button");
24 same( group.find("a > span:not(.ui-corner-left):not(.ui-corner-right)").length, linkCount - 2, "only 2 buttons are cornered");
27 test( "control group buttons should respect theme-related data attributes", function(){
28 var group = $("#control-group-content");
30 ok(!group.find('[data-shadow=false]').hasClass("ui-shadow"),
31 "buttons with data-shadow=false should not have the ui-shadow class");
32 ok(!group.find('[data-corners=false]').hasClass("ui-btn-corner-all"),
33 "buttons with data-corners=false should not have the ui-btn-corner-all class");
34 ok(!group.find('[data-iconshadow=false] .ui-icon').hasClass("ui-icon-shadow"),
35 "buttons with data-iconshadow=false should not have the ui-icon-shadow class on their icons");
38 // Test for issue #3046 and #3054:
39 test( "mousedown on SVG elements should not throw an exception", function(){
40 var svg = $("#embedded-svg"),
43 ok(svg.length > 0, "found embedded svg document" );
44 if ( svg.length > 0 ) {
45 rect = $( "rect", svg );
46 ok(rect.length > 0, "found rect" );
48 rect.trigger("mousedown");
52 ok( success, "mousedown executed without exception");
56 test( "Elements with “data-mini='true'” should have “ui-mini” class attached to enhanced element.", function(){
57 var $mini = $("#mini"),
59 $minicontrol = $('#mini-control');
61 ok( $full.not('.ui-mini'), "Original element does not have data attribute, enhanced version does not recieve .ui-mini.");
62 ok( $mini.is('.ui-mini'), "Original element has data attribute, enhanced version recieves .ui-mini." );
63 ok( $minicontrol.is('.ui-mini'), "Controlgroup has data attribute and recieves .ui-mini.");
66 test( "Ensure icon positioning defaults to left, and can be overridden with “data-iconpos”", function() {
67 var posdefault = $("#iconpos1"),
68 posleft = $("#iconpos2"),
69 posright = $("#iconpos3");
71 ok( posdefault.hasClass("ui-btn-icon-left"), "Button with unspecified icon position gets .ui-btn-icon-left" );
72 ok( posleft.hasClass("ui-btn-icon-left"), "Button with left icon positioning specified .ui-btn-icon-left" );
73 ok( posright.hasClass("ui-btn-icon-right"), "Button with right icon positioning specified .ui-btn-icon-right" );
77 asyncTest( "ui-btn-* should be applied based on a setting", function() {
78 // force touch support so the timeout is set
79 $.support.touch = true;
81 var $btn = $( "#hover-delay" );
83 $.testHelper.sequence([
85 $btn.trigger( "vmousedown" );
89 ok( $btn.attr("class").indexOf( "ui-btn-down" ) == -1, "button doesn't have the down class yet" );
93 ok( $btn.attr("class").indexOf( "ui-btn-down" ) >= 0, "button has the down class yet" );
96 // the value is split and some padding is added to make sure that the last check fires
97 // after the hoverDelay has expired
98 ], $.mobile.buttonMarkup.hoverDelay / 2 + 50 );