fix(core): AugmentObject should check for own propeties correctly (#12534)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-01-09 13:47:42 +01:00
committed by GitHub
parent 5f1adefca7
commit 0cdf393743
2 changed files with 29 additions and 7 deletions

View File

@@ -572,5 +572,22 @@ describe('AugmentObject', () => {
expect('z' in augmentedObject.x).toBe(true);
expect('y' in augmentedObject.x).toBe(true);
});
test('should ignore non-enumerable keys', () => {
const originalObject: { toString?: string } = { toString: '123' };
const augmentedObject = augmentObject(originalObject);
expect('toString' in augmentedObject).toBe(true);
expect(Object.keys(augmentedObject)).toEqual(['toString']);
expect(Object.getOwnPropertyDescriptor(augmentedObject, 'toString')?.value).toEqual(
originalObject.toString,
);
expect(augmentedObject.toString).toEqual(originalObject.toString);
augmentedObject.toString = '456';
expect(augmentedObject.toString).toBe('456');
delete augmentedObject.toString;
expect(augmentedObject.toString).toBeUndefined();
});
});
});