Add bizarro test for Object.getOwnPropertySymbols.

This commit is contained in:
jdalton
2015-04-12 16:00:21 -07:00
parent 20183bbd57
commit 9d90af409b
2 changed files with 40 additions and 8 deletions

View File

@@ -460,6 +460,15 @@
var _now = Date.now;
setProperty(Date, 'now', _.noop);
var _getOwnPropertySymbols = Object.getOwnPropertySymbols;
setProperty(Object, 'getOwnPropertySymbols', (function() {
function getOwnPropertySymbols() {
return [];
}
setProperty(getOwnPropertySymbols, 'toString', createToString('getOwnPropertySymbols'));
return getOwnPropertySymbols;
}()));
var _getPrototypeOf = Object.getPrototypeOf;
setProperty(Object, 'getPrototypeOf', _.noop);
@@ -552,6 +561,7 @@
// Restore built-in methods.
setProperty(Array, 'isArray', _isArray);
setProperty(Date, 'now', _now);
setProperty(Object, 'getOwnPropertySymbols', _getOwnPropertySymbols);
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
setProperty(Object, 'keys', _keys);
@@ -698,7 +708,7 @@
}
});
test('should avoid overwritten native methods', 12, function() {
test('should avoid overwritten native methods', 13, function() {
function Foo() {}
function message(lodashMethod, nativeMethod) {
@@ -724,6 +734,13 @@
}
ok(typeof actual == 'number', message('_.now', 'Date.now'));
try {
actual = lodashBizarro.merge({}, object);
} catch(e) {
actual = null;
}
deepEqual(actual, object, message('_.merge', 'Object.getOwnPropertySymbols'));
try {
actual = [lodashBizarro.isPlainObject({}), lodashBizarro.isPlainObject([])];
} catch(e) {
@@ -792,7 +809,7 @@
}
}
else {
skipTest(12);
skipTest(13);
}
});
}());