mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-15 13:17:50 +00:00
Allow amd builds to test for bizarro methods.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<div id="qunit"></div>
|
||||
<div id="exports"></div>
|
||||
<script>
|
||||
function addBizarroMethods() {
|
||||
// add extensions
|
||||
Function.prototype._method = function() {};
|
||||
|
||||
@@ -42,15 +43,9 @@
|
||||
|
||||
Object._keys = Object.keys;
|
||||
Object.keys = function() {};
|
||||
}
|
||||
|
||||
// load Lo-Dash and expose it to the bad extensions/shims
|
||||
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||
</script>
|
||||
<script>
|
||||
// store Lo-Dash to test for bad extensions/shims
|
||||
var lodashBizarro = window._;
|
||||
|
||||
// restore native methods
|
||||
function removeBizarroMethods() {
|
||||
if (Array._isArray) {
|
||||
Array.isArray = Array._isArray;
|
||||
} else {
|
||||
@@ -94,7 +89,14 @@
|
||||
delete Object._defineProperty;
|
||||
delete Object._getPrototypeOf;
|
||||
delete Object._keys;
|
||||
}
|
||||
|
||||
addBizarroMethods();
|
||||
|
||||
// load Lo-Dash and expose it to the bad extensions/shims
|
||||
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
||||
</script>
|
||||
<script>
|
||||
QUnit.config.hidepassed = true;
|
||||
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
@@ -103,8 +105,10 @@
|
||||
global_test_results = results;
|
||||
});
|
||||
|
||||
// clear existing `_` value
|
||||
// store Lo-Dash to test for bad extensions/shims
|
||||
var lodashBizarro = window._;
|
||||
window._ = undefined;
|
||||
removeBizarroMethods();
|
||||
|
||||
// load Lo-Dash and test scripts
|
||||
document.write(ui.urlParams.loader == 'none'
|
||||
@@ -132,8 +136,8 @@
|
||||
|
||||
QUnit.config.autostart = false;
|
||||
|
||||
// load Lo-Dash as a module
|
||||
require({
|
||||
function getConfig() {
|
||||
return {
|
||||
'baseUrl': './',
|
||||
'urlArgs': 't=' + (+new Date),
|
||||
'packages': [
|
||||
@@ -168,8 +172,11 @@
|
||||
'exports': '_'
|
||||
}
|
||||
}
|
||||
},
|
||||
['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||
};
|
||||
}
|
||||
|
||||
function loadModulesAndTests() {
|
||||
require(getConfig(), ['lodash', 'shimmed', 'underscore'], function(lodash, shimmed, underscore) {
|
||||
if (shimmed && shimmed.noConflict) {
|
||||
shimmedModule = shimmed.noConflict();
|
||||
shimmedModule.moduleName = 'shimmed';
|
||||
@@ -189,6 +196,20 @@
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
if (window.requirejs) {
|
||||
addBizarroMethods();
|
||||
|
||||
require(getConfig(), ['lodash'], function(lodash) {
|
||||
lodashBizarro = lodash;
|
||||
delete requirejs.s.contexts._;
|
||||
|
||||
removeBizarroMethods();
|
||||
loadModulesAndTests();
|
||||
});
|
||||
} else {
|
||||
loadModulesAndTests();
|
||||
}
|
||||
}());
|
||||
|
||||
// set a more readable browser name
|
||||
|
||||
Reference in New Issue
Block a user