mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Avoid object mutation in getRawTag. [closes #2755]
This commit is contained in:
committed by
John-David Dalton
parent
e485e16d28
commit
1c9a9f364d
68
test/test.js
68
test/test.js
@@ -11360,7 +11360,13 @@
|
||||
assert.strictEqual(_.isPlainObject(object), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` for objects with a `Symbol.toStringTag` property', function(assert) {
|
||||
QUnit.test('should return `true` for objects with a `valueOf` property', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(_.isPlainObject({ 'valueOf': 0 }), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` for objects with a writable `Symbol.toStringTag` property', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
if (Symbol && Symbol.toStringTag) {
|
||||
@@ -11374,12 +11380,6 @@
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should return `true` for objects with a `valueOf` property', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
assert.strictEqual(_.isPlainObject({ 'valueOf': 0 }), true);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` for objects with a custom `[[Prototype]]`', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -11387,25 +11387,6 @@
|
||||
assert.strictEqual(_.isPlainObject(object), false);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` for objects with a read-only `Symbol.toStringTag` property', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
if (Symbol && Symbol.toStringTag) {
|
||||
var object = {};
|
||||
defineProperty(object, Symbol.toStringTag, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': 'X'
|
||||
});
|
||||
|
||||
assert.deepEqual(_.isPlainObject(object), false);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` for DOM elements', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -11440,6 +11421,41 @@
|
||||
assert.strictEqual(_.isPlainObject(symbol), false);
|
||||
});
|
||||
|
||||
QUnit.test('should return `false` for objects with a read-only `Symbol.toStringTag` property', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
if (Symbol && Symbol.toStringTag) {
|
||||
var object = {};
|
||||
defineProperty(object, Symbol.toStringTag, {
|
||||
'configurable': true,
|
||||
'enumerable': false,
|
||||
'writable': false,
|
||||
'value': 'X'
|
||||
});
|
||||
|
||||
assert.deepEqual(_.isPlainObject(object), false);
|
||||
}
|
||||
else {
|
||||
skipAssert(assert);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should not mutate `value`', function(assert) {
|
||||
assert.expect(2);
|
||||
|
||||
if (Symbol && Symbol.toStringTag) {
|
||||
var proto = {};
|
||||
proto[Symbol.toStringTag] = undefined;
|
||||
var object = create(proto);
|
||||
|
||||
assert.strictEqual(_.isPlainObject(object), false);
|
||||
assert.notOk(lodashStable.has(object, Symbol.toStringTag));
|
||||
}
|
||||
else {
|
||||
skipAssert(assert, 2);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('should work with objects from another realm', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user