fix(core): augmentObject should use existing property descriptors whenever possible (#5872)

* fix(core): Augmented objects should use existing property descriptors whenever possible

* add a test for non-enumerable keys
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-04-03 17:19:12 +02:00
committed by GitHub
parent 31cd04c476
commit 6a1b7c306b
2 changed files with 18 additions and 8 deletions

View File

@@ -520,5 +520,13 @@ describe('AugmentObject', () => {
expect(timeAugmented).toBeLessThan(timeCopied);
});
test('should ignore non-enumerable keys', () => {
const originalObject = { a: 1, b: 2 };
Object.defineProperty(originalObject, '__hiddenProp', { enumerable: false });
const augmentedObject = augmentObject(originalObject);
expect(Object.keys(augmentedObject)).toEqual(['a', 'b']);
});
});
});