jquery-mobile/tests/unit/buttonMarkup/buttonMarkup_core.js
2012-01-19 09:26:33 -08:00

63 lines
2.2 KiB
JavaScript

/*
* mobile buttonMarkup tests
*/
(function($){
module("jquery.mobile.buttonMarkup.js");
test( "control group buttons should be enhanced inside a footer", function(){
var group, linkCount;
group = $("#control-group-footer");
linkCount = group.find( "a" ).length;
same( group.find("a.ui-btn").length, linkCount, "all 4 links should be buttons");
same( group.find("a > span.ui-corner-left").length, 1, "only 1 left cornered button");
same( group.find("a > span.ui-corner-right").length, 1, "only 1 right cornered button");
same( group.find("a > span:not(.ui-corner-left):not(.ui-corner-right)").length, linkCount - 2, "only 2 buttons are cornered");
});
test( "control group buttons should respect theme-related data attributes", function(){
var group = $("#control-group-content");
ok(!group.find('[data-shadow=false]').hasClass("ui-shadow"),
"buttons with data-shadow=false should not have the ui-shadow class");
ok(!group.find('[data-corners=false]').hasClass("ui-btn-corner-all"),
"buttons with data-corners=false should not have the ui-btn-corner-all class");
ok(!group.find('[data-iconshadow=false] .ui-icon').hasClass("ui-icon-shadow"),
"buttons with data-iconshadow=false should not have the ui-icon-shadow class on their icons");
});
// Test for issue #3046 and #3054:
test( "mousedown on SVG elements should not throw an exception", function(){
var svg = $("#embedded-svg"),
success = true,
rect;
ok(svg.length > 0, "found embedded svg document" );
if ( svg.length > 0 ) {
rect = $( "rect", svg );
ok(rect.length > 0, "found rect" );
try {
rect.trigger("mousedown");
} catch ( ex ) {
success = false;
}
ok( success, "mousedown executed without exception");
}
});
// Test for issue #3141:
test( "elements of input[type='submit'] with data-role='button' should not be doubly enhanced", function(){
var button = $("#double-enhanced"),
count = 0;
button.bind('vclick', function() {
count++;
});
button.trigger('vclick');
ok( count === 1, "events don't trigger twice");
ok( !button.hasClass('ui-btn') && !button.children().length, "input not styled like button and contains no children");
});
})(jQuery);