Fix asyncTests when using an AMD loader.

Former-commit-id: 2a1aa132c9a941205cf495f737f8f9ea2fdc574f
This commit is contained in:
John-David Dalton
2013-07-13 20:22:32 -07:00
parent 8694364aa3
commit 740981376d
4 changed files with 428 additions and 236 deletions

View File

@@ -42,7 +42,6 @@
);
</script>
<script>
// load Lo-Dash as a module
var lodashModule,
shimmedModule,
underscoreModule;
@@ -50,52 +49,58 @@
if (window.curl) {
var require = curl;
}
window.require && require(
(function() {
var reModularize = /modularize/;
if (window.require) {
QUnit.config.autostart = false;
var baseUrl = reModularize.test(ui.urlParams.build)
? '../modularize/'
: '';
// load Lo-Dash as a module
require((function() {
var reModularize = /modularize/;
var modulePath = reModularize.test(ui.urlParams.build)
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
var baseUrl = reModularize.test(ui.urlParams.build)
? '../modularize/'
: '';
return {
'baseUrl': baseUrl,
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': modulePath,
'shimmed': './abc/../' + modulePath,
'underscore': './xyz/../' + modulePath
},
'aliases': [
['shimmed', 'lodash'],
['underscore', 'lodash']
],
'shim': {
'shimmed': {
'exports': '_'
var modulePath = reModularize.test(ui.urlParams.build)
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
return {
'baseUrl': baseUrl,
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': modulePath,
'shimmed': './abc/../' + modulePath,
'underscore': './xyz/../' + modulePath
},
'aliases': [
['shimmed', 'lodash'],
['underscore', 'lodash']
],
'shim': {
'shimmed': {
'exports': '_'
}
}
};
}()),
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
if (shimmed && shimmed.noConflict) {
shimmedModule = shimmed.noConflict();
shimmedModule.moduleName = 'shimmed';
}
};
}()),
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
if (shimmed && shimmed.noConflict) {
shimmedModule = shimmed.noConflict();
shimmedModule.moduleName = 'shimmed';
}
if (underscore && underscore.noConflict) {
underscoreModule = underscore.noConflict();
underscoreModule.moduleName = 'underscore';
}
if (lodash && lodash.noConflict) {
lodashModule = lodash.noConflict();
lodashModule.moduleName = 'lodash';
}
require(['test.js']);
});
if (underscore && underscore.noConflict) {
underscoreModule = underscore.noConflict();
underscoreModule.moduleName = 'underscore';
}
if (lodash && lodash.noConflict) {
lodashModule = lodash.noConflict();
lodashModule.moduleName = 'lodash';
}
require(['test.js'], function() {
QUnit.start();
});
});
}
// set a more readable browser name
window.onload = function() {
@@ -105,7 +110,7 @@
ua.innerHTML = platform;
clearInterval(timeoutId);
}
}, 15);
}, 16);
};
</script>
</body>

View File

@@ -104,39 +104,42 @@
}
if (!window.require) {
init(_);
} else {
QUnit.config.autostart = false;
// load Lo-Dash as a module
require((function() {
var reModularize = /modularize/;
var baseUrl = reModularize.test(ui.urlParams.build)
? '../modularize/'
: '';
var modulePath = reModularize.test(ui.urlParams.build)
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
return {
'baseUrl': baseUrl,
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': modulePath
}
};
}()),
['lodash'], function(lodash) {
init(lodash);
require([
'../vendor/underscore/test/collections.js',
'../vendor/underscore/test/arrays.js',
'../vendor/underscore/test/functions.js',
'../vendor/underscore/test/objects.js',
'../vendor/underscore/test/utility.js'
], function() {
QUnit.start();
});
});
}
// load Lo-Dash as a module
window.require && require(
(function() {
var reModularize = /modularize/;
var baseUrl = reModularize.test(ui.urlParams.build)
? '../modularize/'
: '';
var modulePath = reModularize.test(ui.urlParams.build)
? 'lodash'
: ui.buildPath.replace(/\.js$/, '');
return {
'baseUrl': baseUrl,
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': modulePath
}
};
}()),
['lodash'], function(lodash) {
init(lodash);
require([
'../vendor/underscore/test/collections.js',
'../vendor/underscore/test/arrays.js',
'../vendor/underscore/test/functions.js',
'../vendor/underscore/test/objects.js',
'../vendor/underscore/test/utility.js',
'../vendor/underscore/test/utility.js'
]);
});
</script>
<script type="text/html" id="template">
<%