mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Replace var window with root in test.js.
This commit is contained in:
54
test/test.js
54
test/test.js
@@ -1,15 +1,15 @@
|
|||||||
;(function(window, undefined) {
|
;(function(root, undefined) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** Object shortcuts */
|
/** Object shortcuts */
|
||||||
var phantom = window.phantom,
|
var phantom = root.phantom,
|
||||||
process = window.process,
|
process = root.process,
|
||||||
system = window.system;
|
system = root.system;
|
||||||
|
|
||||||
/** The file path of the Lo-Dash file to test */
|
/** The file path of the Lo-Dash file to test */
|
||||||
var filePath = (function() {
|
var filePath = (function() {
|
||||||
var min = 0,
|
var min = 0,
|
||||||
args = window.arguments,
|
args = root.arguments,
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
if (phantom) {
|
if (phantom) {
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
/** The `ui` object */
|
/** The `ui` object */
|
||||||
var ui = window.ui || (window.ui = {
|
var ui = root.ui || (root.ui = {
|
||||||
'buildPath': filePath,
|
'buildPath': filePath,
|
||||||
'loaderPath': '',
|
'loaderPath': '',
|
||||||
'urlParams': {}
|
'urlParams': {}
|
||||||
@@ -87,21 +87,21 @@
|
|||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/** Method and object shortcuts */
|
/** Method and object shortcuts */
|
||||||
var document = !phantom && window.document,
|
var document = !phantom && root.document,
|
||||||
amd = window.define && define.amd,
|
amd = root.define && define.amd,
|
||||||
body = document && document.body,
|
body = document && document.body,
|
||||||
create = Object.create,
|
create = Object.create,
|
||||||
freeze = Object.freeze,
|
freeze = Object.freeze,
|
||||||
push = Array.prototype.push,
|
push = Array.prototype.push,
|
||||||
slice = Array.prototype.slice,
|
slice = Array.prototype.slice,
|
||||||
toString = Object.prototype.toString,
|
toString = Object.prototype.toString,
|
||||||
Worker = !phantom && window.Worker;
|
Worker = !phantom && root.Worker;
|
||||||
|
|
||||||
/** Detects if running in a PhantomJS web page */
|
/** Detects if running in a PhantomJS web page */
|
||||||
var isPhantomPage = typeof callPhantom == 'function';
|
var isPhantomPage = typeof callPhantom == 'function';
|
||||||
|
|
||||||
/** Use a single "load" function */
|
/** Use a single "load" function */
|
||||||
var load = !amd && typeof require == 'function' ? require : window.load;
|
var load = !amd && typeof require == 'function' ? require : root.load;
|
||||||
|
|
||||||
/** The basename of the Lo-Dash file to test */
|
/** The basename of the Lo-Dash file to test */
|
||||||
var basename = /[\w.-]+$/.exec(filePath)[0];
|
var basename = /[\w.-]+$/.exec(filePath)[0];
|
||||||
@@ -109,21 +109,21 @@
|
|||||||
/** The unit testing framework */
|
/** The unit testing framework */
|
||||||
var QUnit = (function() {
|
var QUnit = (function() {
|
||||||
var noop = Function.prototype;
|
var noop = Function.prototype;
|
||||||
return window.QUnit || (
|
return root.QUnit || (
|
||||||
window.addEventListener || (window.addEventListener = noop),
|
root.addEventListener || (root.addEventListener = noop),
|
||||||
window.setTimeout || (window.setTimeout = noop),
|
root.setTimeout || (root.setTimeout = noop),
|
||||||
window.QUnit = load('../vendor/qunit/qunit/qunit.js') || window.QUnit,
|
root.QUnit = load('../vendor/qunit/qunit/qunit.js') || root.QUnit,
|
||||||
(load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(window),
|
(load('../vendor/qunit-clib/qunit-clib.js') || { 'runInContext': noop }).runInContext(root),
|
||||||
addEventListener === noop && delete window.addEventListener,
|
addEventListener === noop && delete root.addEventListener,
|
||||||
window.QUnit
|
root.QUnit
|
||||||
);
|
);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/** The `lodash` function to test */
|
/** The `lodash` function to test */
|
||||||
var _ = window._ || (window._ = (
|
var _ = root._ || (root._ = (
|
||||||
_ = load(filePath) || window._,
|
_ = load(filePath) || root._,
|
||||||
_ = _._ || _,
|
_ = _._ || _,
|
||||||
(_.runInContext ? _.runInContext(window) : _)
|
(_.runInContext ? _.runInContext(root) : _)
|
||||||
));
|
));
|
||||||
|
|
||||||
/** Used to pass falsey values to methods */
|
/** Used to pass falsey values to methods */
|
||||||
@@ -2178,7 +2178,7 @@
|
|||||||
strictEqual(_.isPlainObject(arguments), false);
|
strictEqual(_.isPlainObject(arguments), false);
|
||||||
strictEqual(_.isPlainObject(Error), false);
|
strictEqual(_.isPlainObject(Error), false);
|
||||||
strictEqual(_.isPlainObject(Math), false);
|
strictEqual(_.isPlainObject(Math), false);
|
||||||
strictEqual(_.isPlainObject(window), false);
|
strictEqual(_.isPlainObject(root), false);
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -2232,7 +2232,7 @@
|
|||||||
test('should return `false` for subclassed values', function() {
|
test('should return `false` for subclassed values', function() {
|
||||||
_.forEach(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) {
|
_.forEach(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) {
|
||||||
function Foo() {}
|
function Foo() {}
|
||||||
Foo.prototype = window[methodName.slice(2)].prototype;
|
Foo.prototype = root[methodName.slice(2)].prototype;
|
||||||
|
|
||||||
var object = new Foo;
|
var object = new Foo;
|
||||||
if (toString.call(object) == '[object Object]') {
|
if (toString.call(object) == '[object Object]') {
|
||||||
@@ -3750,7 +3750,7 @@
|
|||||||
var callCount = 0,
|
var callCount = 0,
|
||||||
dateCount = 0;
|
dateCount = 0;
|
||||||
|
|
||||||
var lodash = _.runInContext(_.assign({}, window, {
|
var lodash = _.runInContext(_.assign({}, root, {
|
||||||
'Date': function() {
|
'Date': function() {
|
||||||
return ++dateCount < 3 ? new Date : Object(Infinity);
|
return ++dateCount < 3 ? new Date : Object(Infinity);
|
||||||
}
|
}
|
||||||
@@ -4537,8 +4537,8 @@
|
|||||||
var acceptFalsey = _.difference(allMethods, rejectFalsey);
|
var acceptFalsey = _.difference(allMethods, rejectFalsey);
|
||||||
|
|
||||||
test('should accept falsey arguments', function() {
|
test('should accept falsey arguments', function() {
|
||||||
var isExported = '_' in window,
|
var isExported = '_' in root,
|
||||||
oldDash = window._;
|
oldDash = root._;
|
||||||
|
|
||||||
|
|
||||||
_.forEach(acceptFalsey, function(methodName) {
|
_.forEach(acceptFalsey, function(methodName) {
|
||||||
@@ -4557,9 +4557,9 @@
|
|||||||
|
|
||||||
if (methodName == 'noConflict') {
|
if (methodName == 'noConflict') {
|
||||||
if (isExported) {
|
if (isExported) {
|
||||||
window._ = oldDash;
|
root._ = oldDash;
|
||||||
} else {
|
} else {
|
||||||
delete window._;
|
delete root._;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_.indexOf(returnArrays, methodName) > -1) {
|
if (_.indexOf(returnArrays, methodName) > -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user