mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Cleanup tests.
This commit is contained in:
36
test/test.js
36
test/test.js
@@ -188,7 +188,7 @@
|
|||||||
/** Detects if running the pre-build version of Lo-Dash */
|
/** Detects if running the pre-build version of Lo-Dash */
|
||||||
var isPreBuild = /getHolders/.test(_.partial(_.noop));
|
var isPreBuild = /getHolders/.test(_.partial(_.noop));
|
||||||
|
|
||||||
/** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */
|
/** Used to check problem JScript properties (a.k.a. the `[[DontEnum]]` bug) */
|
||||||
var shadowedProps = [
|
var shadowedProps = [
|
||||||
'constructor',
|
'constructor',
|
||||||
'hasOwnProperty',
|
'hasOwnProperty',
|
||||||
@@ -326,7 +326,7 @@
|
|||||||
var _now = Date.now;
|
var _now = Date.now;
|
||||||
setProperty(Date, 'now', function() {});
|
setProperty(Date, 'now', function() {});
|
||||||
|
|
||||||
var _create = Object.create;
|
var _create = create;
|
||||||
setProperty(Object, 'create', function() {});
|
setProperty(Object, 'create', function() {});
|
||||||
|
|
||||||
var _defineProperty = Object.defineProperty;
|
var _defineProperty = Object.defineProperty;
|
||||||
@@ -2867,19 +2867,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should work with extremely large arrays', 1, function() {
|
test('should work with extremely large arrays', 1, function() {
|
||||||
var expected = Array(5e5),
|
// test in modern browsers
|
||||||
pass = true;
|
|
||||||
|
|
||||||
if (freeze) {
|
if (freeze) {
|
||||||
try {
|
try {
|
||||||
var actual = _.flatten([expected]);
|
var expected = Array(5e5),
|
||||||
|
actual = _.flatten([expected]);
|
||||||
|
|
||||||
|
deepEqual(actual, expected)
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
pass = false;
|
ok(false);
|
||||||
}
|
|
||||||
if (pass) {
|
|
||||||
deepEqual(actual, expected);
|
|
||||||
} else {
|
|
||||||
ok(pass);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
skipTest();
|
skipTest();
|
||||||
@@ -3183,7 +3179,7 @@
|
|||||||
_.each(['forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight'], function(methodName) {
|
_.each(['forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight'], function(methodName) {
|
||||||
var func = _[methodName];
|
var func = _[methodName];
|
||||||
|
|
||||||
test('`_.' + methodName + '` fixes the JScript [[DontEnum]] bug (test in IE < 9)', 1, function() {
|
test('`_.' + methodName + '` fixes the JScript `[[DontEnum]]` bug (test in IE < 9)', 1, function() {
|
||||||
var props = [];
|
var props = [];
|
||||||
func(shadowedObject, function(value, prop) { props.push(prop); });
|
func(shadowedObject, function(value, prop) { props.push(prop); });
|
||||||
deepEqual(props.sort(), shadowedProps);
|
deepEqual(props.sort(), shadowedProps);
|
||||||
@@ -4222,7 +4218,7 @@
|
|||||||
strictEqual(_.isEmpty({ 'length': '0' }), false);
|
strictEqual(_.isEmpty({ 'length': '0' }), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', 1, function() {
|
test('fixes the JScript `[[DontEnum]]` bug (test in IE < 9)', 1, function() {
|
||||||
strictEqual(_.isEmpty(shadowedObject), false);
|
strictEqual(_.isEmpty(shadowedObject), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -4501,7 +4497,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', 1, function() {
|
test('fixes the JScript `[[DontEnum]]` bug (test in IE < 9)', 1, function() {
|
||||||
strictEqual(_.isEqual(shadowedObject, {}), false);
|
strictEqual(_.isEqual(shadowedObject, {}), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -4678,7 +4674,7 @@
|
|||||||
strictEqual(_.isEqual(new Foo, otherObject), false);
|
strictEqual(_.isEqual(new Foo, otherObject), false);
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
var object = Object.create(null);
|
var object = create(null);
|
||||||
object.a = 1;
|
object.a = 1;
|
||||||
strictEqual(_.isEqual(object, otherObject), true);
|
strictEqual(_.isEqual(object, otherObject), true);
|
||||||
}
|
}
|
||||||
@@ -5062,7 +5058,7 @@
|
|||||||
strictEqual(_.isPlainObject(new Foo(1)), false);
|
strictEqual(_.isPlainObject(new Foo(1)), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return `true` for objects a [[Prototype]] of `null`', 1, function() {
|
test('should return `true` for objects with a `[[Prototype]]` of `null`', 1, function() {
|
||||||
if (create) {
|
if (create) {
|
||||||
strictEqual(_.isPlainObject(create(null)), true);
|
strictEqual(_.isPlainObject(create(null)), true);
|
||||||
} else {
|
} else {
|
||||||
@@ -5092,7 +5088,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return `false` for Object objects without a [[Class]] of "Object"', 3, function() {
|
test('should return `false` for Object objects without a `[[Class]]` of "Object"', 3, function() {
|
||||||
strictEqual(_.isPlainObject(arguments), false);
|
strictEqual(_.isPlainObject(arguments), false);
|
||||||
strictEqual(_.isPlainObject(Error), false);
|
strictEqual(_.isPlainObject(Error), false);
|
||||||
strictEqual(_.isPlainObject(Math), false);
|
strictEqual(_.isPlainObject(Math), false);
|
||||||
@@ -5392,7 +5388,7 @@
|
|||||||
delete String.prototype.a;
|
delete String.prototype.a;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` fixes the JScript [[DontEnum]] bug (test in IE < 9)', 2, function() {
|
test('`_.' + methodName + '` fixes the JScript `[[DontEnum]]` bug (test in IE < 9)', 2, function() {
|
||||||
function Foo() {}
|
function Foo() {}
|
||||||
Foo.prototype.a = 1;
|
Foo.prototype.a = 1;
|
||||||
|
|
||||||
@@ -7872,7 +7868,7 @@
|
|||||||
strictEqual(_.size({ 'length': '0' }), 1);
|
strictEqual(_.size({ 'length': '0' }), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fixes the JScript [[DontEnum]] bug (test in IE < 9)', 1, function() {
|
test('fixes the JScript `[[DontEnum]]` bug (test in IE < 9)', 1, function() {
|
||||||
strictEqual(_.size(shadowedObject), 7);
|
strictEqual(_.size(shadowedObject), 7);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user