mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): AugmentObject should handle the constructor property correctly (#12744)
This commit is contained in:
committed by
GitHub
parent
af5b64a61d
commit
36bc164da4
@@ -10,6 +10,8 @@ describe('AugmentObject', () => {
|
||||
|
||||
const augmentedObject = augmentArray(originalObject);
|
||||
|
||||
expect(augmentedObject.constructor.name).toEqual('Array');
|
||||
|
||||
expect(augmentedObject.push(5)).toEqual(6);
|
||||
expect(augmentedObject).toEqual([1, 2, 3, 4, null, 5]);
|
||||
expect(originalObject).toEqual(copyOriginal);
|
||||
@@ -207,6 +209,8 @@ describe('AugmentObject', () => {
|
||||
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
expect(augmentedObject.constructor.name).toEqual('Object');
|
||||
|
||||
augmentedObject[1] = 911;
|
||||
expect(originalObject[1]).toEqual(11);
|
||||
expect(augmentedObject[1]).toEqual(911);
|
||||
@@ -589,5 +593,29 @@ describe('AugmentObject', () => {
|
||||
delete augmentedObject.toString;
|
||||
expect(augmentedObject.toString).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should handle constructor property correctly', () => {
|
||||
const originalObject: any = {
|
||||
a: {
|
||||
b: {
|
||||
c: {
|
||||
d: '4',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const augmentedObject = augmentObject(originalObject);
|
||||
|
||||
expect(augmentedObject.constructor.name).toEqual('Object');
|
||||
expect(augmentedObject.a.constructor.name).toEqual('Object');
|
||||
expect(augmentedObject.a.b.constructor.name).toEqual('Object');
|
||||
expect(augmentedObject.a.b.c.constructor.name).toEqual('Object');
|
||||
|
||||
augmentedObject.constructor = {};
|
||||
expect(augmentedObject.constructor.name).toEqual('Object');
|
||||
|
||||
delete augmentedObject.constructor;
|
||||
expect(augmentedObject.constructor.name).toEqual('Object');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user