added tests for basic support attributes

This commit is contained in:
John Bender 2010-11-20 15:26:13 +08:00 committed by Scott Jehl
parent 3cb0e3c2d0
commit d94b2c536b
2 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery Mobile Support Test Suite</title>
<script type="text/javascript" src="../../../js/jquery.js"></script>
<script type="text/javascript" src="../../../js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../js/jquery.mobile.widget.js"></script>
<script type="text/javascript" src="../../../js/jquery.mobile.media.js"></script>
<script type="text/javascript" src="../../../js/jquery.mobile.support.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
<script type="text/javascript" src="../../../external/qunit.js"></script>
<script type="text/javascript" src="support_core.js"></script>
</head>
<body>
<h1 id="qunit-header">jQuery Mobile Support Test Suite</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
<div id="widget-wrapper">
<div id="widget">
<div>...</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,36 @@
/*
* mobile support unit tests
*/
(function( $ ) {
var reloadLib = function(){
$("script[src$=support.js]").appendTo("body");
};
module("mobile.support", {
teardown: function(){
$("body script[src$=support.js]").remove();
}
});
// NOTE test has debatable value, only prevents property name changes
// and improper sources for attribute checks
test( "detects functionality from basic properties and attributes", function(){
// TODO expose properties for less brittle tests
$.extend(window, {
orientation: true,
WebKitTransitionEvent: true
});
document["ontouchend"] = true;
history.pushState = function(){};
$.mobile.media = function(){ return true; };
reloadLib();
ok($.support.orientation);
ok($.support.cssTransitions);
ok($.support.touch);
ok($.support.pushState);
ok($.support.mediaquery);
});
})(jQuery);