mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Add more lodashBadShim tests.
This commit is contained in:
18
test/test.js
18
test/test.js
@@ -353,22 +353,21 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('avoids overwritten native methods', 6, function() {
|
test('avoids overwritten native methods', 7, function() {
|
||||||
function Foo() {}
|
function Foo() {}
|
||||||
|
|
||||||
function message(methodName) {
|
function message(methodName) {
|
||||||
return '`_.' + methodName + '` should avoid overwritten native methods';
|
return '`_.' + methodName + '` should avoid overwritten native methods';
|
||||||
}
|
}
|
||||||
|
|
||||||
var object = { 'a': true };
|
var object = { 'a': true };
|
||||||
|
|
||||||
if (lodashBadShim) {
|
if (lodashBadShim) {
|
||||||
try {
|
try {
|
||||||
actual = lodashBadShim.isArray([]);
|
actual = [lodashBadShim.isArray([]), lodashBadShim.isArray({ 'length': 0 })];
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
actual = null;
|
actual = null;
|
||||||
}
|
}
|
||||||
ok(actual, message('Array.isArray'));
|
deepEqual(actual, [true, false], message('Array.isArray'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
actual = lodashBadShim.now();
|
actual = lodashBadShim.now();
|
||||||
@@ -378,11 +377,12 @@
|
|||||||
ok(typeof actual == 'number', message('Date.now'));
|
ok(typeof actual == 'number', message('Date.now'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
actual = lodashBadShim.create(Foo.prototype, object);
|
actual = [lodashBadShim.create(Foo.prototype, object), lodashBadShim.create()];
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
actual = null;
|
actual = null;
|
||||||
}
|
}
|
||||||
ok(actual instanceof Foo, message('Object.create'));
|
ok(actual[0] instanceof Foo, message('Object.create'));
|
||||||
|
deepEqual(actual[1], {}, message('Object.create'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var actual = lodashBadShim.bind(function() { return this.a; }, object)();
|
var actual = lodashBadShim.bind(function() { return this.a; }, object)();
|
||||||
@@ -399,14 +399,14 @@
|
|||||||
deepEqual(actual, [true, false], message('Object.getPrototypeOf'));
|
deepEqual(actual, [true, false], message('Object.getPrototypeOf'));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
actual = lodashBadShim.keys(object);
|
actual = [lodashBadShim.keys(object), lodashBadShim.keys()];
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
actual = null;
|
actual = null;
|
||||||
}
|
}
|
||||||
deepEqual(actual, ['a'], message('Object.keys'));
|
deepEqual(actual, [['a'], []], message('Object.keys'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipTest(6);
|
skipTest(7);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user