Switched to using AMD loader and $.testHelper.reloadModule instead of $.testHelper.reloadLib

This commit is contained in:
Ghislain Seguin 2012-01-18 11:10:02 -08:00
parent 2034c3607e
commit 1950602dcb
2 changed files with 49 additions and 33 deletions

View file

@ -5,18 +5,27 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Support Test Suite</title>
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/jquery.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../js/jquery.mobile.define.js"></script>
<script src="../../../js/jquery.ui.widget.js"></script>
<script src="../../../js/jquery.mobile.widget.js"></script>
<script src="../../../js/jquery.mobile.media.js"></script>
<script src="../../../js/jquery.mobile.support.js"></script>
<link rel="stylesheet" href="../../../external/qunit.css"/>
<script src="../jquery.setNameSpace.js"></script>
<script src="../../../external/qunit.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="support_core.js"></script>
<script>
$.testHelper.asyncLoad([
[
"jquery.mobile.support"
],
[
"support_core.js"
]
]);
</script>
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit.css"/>
<script src="../../../js/jquery.mobile.support.js"></script>
<script src="../swarminject.js"></script>
</head>

View file

@ -4,9 +4,9 @@
$.testHelper.excludeFileProtocol(function(){
var prependToFn = $.fn.prependTo,
libName = "jquery.mobile.support.js";
moduleName = "jquery.mobile.support";
module(libName, {
module(moduleName, {
teardown: function(){
//NOTE undo any mocking
$.fn.prependTo = prependToFn;
@ -15,7 +15,7 @@ $.testHelper.excludeFileProtocol(function(){
// NOTE following two tests have debatable value as they only
// prevent property name changes and improper attribute checks
test( "detects functionality from basic affirmative properties and attributes", function(){
asyncTest( "detects functionality from basic affirmative properties and attributes", function(){
// TODO expose properties for less brittle tests
$.extend(window, {
WebKitTransitionEvent: true,
@ -30,23 +30,25 @@ $.testHelper.excludeFileProtocol(function(){
$.mobile.media = function(){ return true; };
$.testHelper.reloadLib(libName);
ok($.support.orientation);
ok($.support.touch);
ok($.support.cssTransitions);
ok($.support.pushState);
ok($.support.mediaquery);
$.testHelper.reloadModule( moduleName ).done( function() {
ok($.support.orientation);
ok($.support.touch);
ok($.support.cssTransitions);
ok($.support.pushState);
ok($.support.mediaquery);
start();
});
});
test( "detects functionality from basic negative properties and attributes (where possible)", function(){
asyncTest( "detects functionality from basic negative properties and attributes (where possible)", function(){
delete window["orientation"];
delete document["ontouchend"];
$.testHelper.reloadLib(libName);
ok(!$.support.orientation);
ok(!$.support.touch);
$.testHelper.reloadModule( moduleName ).done( function() {
ok(!$.support.orientation);
ok(!$.support.touch);
start();
});
});
// NOTE mocks prependTo to simulate base href updates or lack thereof
@ -61,21 +63,24 @@ $.testHelper.excludeFileProtocol(function(){
};
};
test( "detects dynamic base tag when new base element added and base href updates", function(){
asyncTest( "detects dynamic base tag when new base element added and base href updates", function(){
mockBaseCheck(location.protocol + '//' + location.host + location.pathname + "ui-dir/");
$.testHelper.reloadLib(libName);
ok($.support.dynamicBaseTag);
$.testHelper.reloadModule( moduleName ).done( function() {
ok($.support.dynamicBaseTag);
start();
});
});
test( "detects no dynamic base tag when new base element added and base href unchanged", function(){
asyncTest( "detects no dynamic base tag when new base element added and base href unchanged", function(){
mockBaseCheck('testurl');
$.testHelper.reloadLib(libName);
ok(!$.support.dynamicBaseTag);
$.testHelper.reloadModule( moduleName ).done( function() {
ok(!$.support.dynamicBaseTag);
start();
});
});
test( "jQM's IE browser check properly detects IE versions", function(){
$.testHelper.reloadLib(libName);
asyncTest( "jQM's IE browser check properly detects IE versions", function(){
$.testHelper.reloadModule( moduleName ).done( function() {
//here we're just comparing our version to what the conditional compilation finds
var ie = !!$.browser.msie, //get a boolean
version = parseInt( $.browser.version, 10),
@ -87,6 +92,8 @@ $.testHelper.excludeFileProtocol(function(){
else{
same(ie, jqmdetectedver, "It's not IE");
}
start();
});
});