Allow switching the module loader in the unit tests.

Former-commit-id: 8521e92925cbca8ff73adf3f1a350caa662e27f7
This commit is contained in:
John-David Dalton
2013-07-07 16:24:26 -07:00
parent b1b06a38af
commit 9b21656314
4 changed files with 74 additions and 36 deletions

View File

@@ -36,9 +36,9 @@
document.write('<script src="../' + ui.buildPath + '"><\/script>');
// load test.js if not using require.js
document.write(QUnit.urlParams.norequire
document.write(QUnit.urlParams.loader == 'none'
? '<script src="test.js"><\/script>'
: '<script src="../vendor/requirejs/require.js"><\/script>'
: '<script data-dojo-config="async:1,parseOnLoad:false" src="../' + ui.loaderPath + '"><\/script>'
);
</script>
<script>
@@ -47,30 +47,33 @@
shimmedModule,
underscoreModule;
if (window.curl) {
var require = curl;
}
window.require && require(
(function() {
var modulePath = ui.buildPath.replace(/\.js$/, '');
return {
'baseUrl': '../vendor/requirejs/',
'baseUrl': './',
'urlArgs': 't=' + (+new Date),
'paths': {
'lodash': '../../' + modulePath,
'shimmed': './../../' + modulePath,
'underscore': '../underscore/../../' + modulePath
'lodash': '../' + modulePath,
'shimmed': '../abc/../' + modulePath,
'underscore': '../xyz/../' + modulePath
},
'aliases': [
['shimmed', 'lodash'],
['underscore', 'lodash']
],
'shim': {
'shimmed': {
'exports': '_'
'exports': '_'
}
}
};
}()),
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
if (lodash && lodash.noConflict) {
lodashModule = lodash.noConflict();
lodashModule.moduleName = 'lodash';
}
if (shimmed.noConflict) {
if (shimmed && shimmed.noConflict) {
shimmedModule = shimmed.noConflict();
shimmedModule.moduleName = 'shimmed';
}
@@ -78,6 +81,10 @@
underscoreModule = underscore.noConflict();
underscoreModule.moduleName = 'underscore';
}
if (lodash && lodash.noConflict) {
lodashModule = lodash.noConflict();
lodashModule.moduleName = 'lodash';
}
require(['test.js']);
});