mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Add RequireJS "shim" test and a build test to ensure the AMD snippet is maintained for r.js.
Former-commit-id: 708c07877cfca0022d6d56c16c36d8bae79e4796
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
<script>
|
<script>
|
||||||
// load Lo-Dash as a module
|
// load Lo-Dash as a module
|
||||||
var lodashModule,
|
var lodashModule,
|
||||||
|
shimmedModule,
|
||||||
underscoreModule;
|
underscoreModule;
|
||||||
|
|
||||||
window.require && require({
|
window.require && require({
|
||||||
@@ -51,14 +52,24 @@
|
|||||||
'urlArgs': 't=' + (+new Date),
|
'urlArgs': 't=' + (+new Date),
|
||||||
'paths': {
|
'paths': {
|
||||||
'lodash': '../../' + QUnit.config.lodashFilename,
|
'lodash': '../../' + QUnit.config.lodashFilename,
|
||||||
'underscore': './../../' + QUnit.config.lodashFilename
|
'shimmed': './../../' + QUnit.config.lodashFilename,
|
||||||
|
'underscore': '../underscore/../../' + QUnit.config.lodashFilename
|
||||||
|
},
|
||||||
|
'shim': {
|
||||||
|
'shimmed': {
|
||||||
|
'exports': '_'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
['lodash', 'underscore'], function(lodash, underscore) {
|
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||||
if (lodash.noConflict) {
|
if (lodash.noConflict) {
|
||||||
lodashModule = lodash.noConflict();
|
lodashModule = lodash.noConflict();
|
||||||
lodashModule.moduleName = 'lodash';
|
lodashModule.moduleName = 'lodash';
|
||||||
}
|
}
|
||||||
|
if (shimmed.noConflict) {
|
||||||
|
shimmedModule = shimmed.noConflict();
|
||||||
|
shimmedModule.moduleName = 'shimmed';
|
||||||
|
}
|
||||||
if (underscore.noConflict) {
|
if (underscore.noConflict) {
|
||||||
underscoreModule = underscore.noConflict();
|
underscoreModule = underscore.noConflict();
|
||||||
underscoreModule.moduleName = 'underscore';
|
underscoreModule.moduleName = 'underscore';
|
||||||
|
|||||||
@@ -422,6 +422,23 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('minified AMD snippet');
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var start = _.once(QUnit.start);
|
||||||
|
|
||||||
|
asyncTest('`lodash`', function() {
|
||||||
|
build(['-s'], function(source, filepath) {
|
||||||
|
// used by r.js build optimizer
|
||||||
|
var defineHasRegExp = /typeof\s+define\s*==(=)?\s*['"]function['"]\s*&&\s*typeof\s+define\.amd\s*==(=)?\s*['"]object['"]\s*&&\s*define\.amd/g;
|
||||||
|
ok(!!defineHasRegExp.exec(source));
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}());
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('strict modifier');
|
QUnit.module('strict modifier');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
@@ -123,6 +123,14 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('supports loading lodash.js with the Require.js "shim" configuration option', function() {
|
||||||
|
if (window.document && window.require) {
|
||||||
|
equal((shimmedModule || {}).moduleName, 'shimmed');
|
||||||
|
} else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('supports loading lodash.js as the "underscore" module', function() {
|
test('supports loading lodash.js as the "underscore" module', function() {
|
||||||
if (window.document && window.require) {
|
if (window.document && window.require) {
|
||||||
equal((underscoreModule || {}).moduleName, 'underscore');
|
equal((underscoreModule || {}).moduleName, 'underscore');
|
||||||
|
|||||||
Reference in New Issue
Block a user