mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
183 lines
4.8 KiB
HTML
183 lines
4.8 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Lo-Dash Test Suite</title>
|
|
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css">
|
|
<style>
|
|
#exports {
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<script src="../vendor/qunit/qunit/qunit.js"></script>
|
|
<script src="../vendor/platform.js/platform.js"></script>
|
|
<script src="./asset/test-ui.js"></script>
|
|
<div id="qunit"></div>
|
|
<div id="exports"></div>
|
|
<script>
|
|
// set bad shims
|
|
Array._isArray = Array.isArray;
|
|
Array.isArray = function() { return false; };
|
|
|
|
Function.prototype._bind = Function.prototype.bind;
|
|
Function.prototype.bind = function() { return function() {}; };
|
|
|
|
Object._create = Object.create;
|
|
Object.create = function() {};
|
|
|
|
Object._defineProperty = Object.defineProperty;
|
|
Object.defineProperty = function() {};
|
|
|
|
Object._keys = Object.keys;
|
|
Object.keys = function() { return []; };
|
|
|
|
// load Lo-Dash and expose it to the bad `Object.keys` shim
|
|
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
|
</script>
|
|
<script>
|
|
// store Lo-Dash to test for bad shim detection
|
|
var lodashBadShim = window._;
|
|
|
|
// restore native methods
|
|
if (Array._isArray) {
|
|
Array.isArray = Array._isArray;
|
|
} else {
|
|
delete Array.isArray;
|
|
}
|
|
if (Function.prototype._bind) {
|
|
Function.prototype.bind = Function.prototype._bind;
|
|
} else {
|
|
delete Function.prototype.bind;
|
|
}
|
|
if (Object._create) {
|
|
Object.create = Object._create;
|
|
} else {
|
|
delete Object.create;
|
|
}
|
|
if (Object._defineProperty) {
|
|
Object.defineProperty = Object._defineProperty;
|
|
} else {
|
|
delete Object.defineProperty;
|
|
}
|
|
if (Object._keys) {
|
|
Object.keys = Object._keys;
|
|
} else {
|
|
delete Object.keys;
|
|
}
|
|
delete Array._isArray;
|
|
delete Function.prototype._bind;
|
|
delete Object._create;
|
|
delete Object._defineProperty;
|
|
delete Object._keys;
|
|
|
|
// report test results in a global for Sauce Labs
|
|
var global_test_results;
|
|
QUnit.done(function(results) {
|
|
global_test_results = results;
|
|
});
|
|
|
|
// load Lo-Dash again to overwrite the existing `_` value
|
|
document.write('<script src="' + (ui.isModularize ? '../lodash.js' : ui.buildPath) + '"><\/script>');
|
|
|
|
// load test.js if not using require.js
|
|
document.write(ui.urlParams.loader == 'none'
|
|
? '<script src="test.js"><\/script>'
|
|
: '<script data-dojo-config="async:1" src="' + ui.loaderPath + '"><\/script>'
|
|
);
|
|
</script>
|
|
<script>
|
|
var lodashModule,
|
|
shimmedModule,
|
|
underscoreModule;
|
|
|
|
(function() {
|
|
if (window.curl) {
|
|
curl.config({ 'apiName': 'require' });
|
|
}
|
|
if (!window.require) {
|
|
return;
|
|
}
|
|
var reBasename = /[\w.-]+$/,
|
|
basePath = ('//' + location.host + location.pathname.replace(reBasename, '')).replace(/\btest\/$/, ''),
|
|
modulePath = ui.buildPath.replace(/\.js$/, ''),
|
|
locationPath = modulePath.replace(reBasename, ''),
|
|
moduleMain = modulePath.match(reBasename)[0];
|
|
|
|
QUnit.config.autostart = false;
|
|
QUnit.config.hidepassed = true;
|
|
|
|
// load Lo-Dash as a module
|
|
require({
|
|
'baseUrl': './',
|
|
'urlArgs': 't=' + (+new Date),
|
|
'packages': [
|
|
{
|
|
'name': 'lodash',
|
|
'location': locationPath,
|
|
'main': moduleMain
|
|
},
|
|
{
|
|
'name': 'shimmed',
|
|
'location': './abc/../' + locationPath,
|
|
'main': moduleMain
|
|
},
|
|
{
|
|
'name': 'underscore',
|
|
'location': './xyz/../' + locationPath,
|
|
'main': moduleMain
|
|
},
|
|
{
|
|
'name': 'test',
|
|
'location': basePath + '/test',
|
|
'main': 'test',
|
|
'config': {
|
|
// work around no global being exported
|
|
'exports': 'QUnit',
|
|
'loader': 'curl/loader/legacy'
|
|
}
|
|
}
|
|
],
|
|
'shim': {
|
|
'shimmed': {
|
|
'exports': '_'
|
|
}
|
|
}
|
|
},
|
|
['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';
|
|
}
|
|
if (ui.isModularize) {
|
|
window._ = lodash;
|
|
}
|
|
require(['test'], function() {
|
|
QUnit.start();
|
|
});
|
|
});
|
|
}());
|
|
|
|
// set a more readable browser name
|
|
window.onload = function() {
|
|
var timeoutId = setInterval(function() {
|
|
var ua = document.getElementById('qunit-userAgent');
|
|
if (ua) {
|
|
ua.innerHTML = platform;
|
|
clearInterval(timeoutId);
|
|
}
|
|
}, 16);
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|