mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Move copyInputItems to node helpers (no-changelog) (#7299)
This commit is contained in:
committed by
GitHub
parent
34bda535e6
commit
597669aa62
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
copyInputItems,
|
||||
getBinaryDataBuffer,
|
||||
parseIncomingMessage,
|
||||
proxyRequestToAxios,
|
||||
@@ -297,4 +298,52 @@ describe('NodeExecuteFunctions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyInputItems', () => {
|
||||
it('should pick only selected properties', () => {
|
||||
const output = copyInputItems(
|
||||
[
|
||||
{
|
||||
json: {
|
||||
a: 1,
|
||||
b: true,
|
||||
c: {},
|
||||
},
|
||||
},
|
||||
],
|
||||
['a'],
|
||||
);
|
||||
expect(output).toEqual([{ a: 1 }]);
|
||||
});
|
||||
|
||||
it('should convert undefined to null', () => {
|
||||
const output = copyInputItems(
|
||||
[
|
||||
{
|
||||
json: {
|
||||
a: undefined,
|
||||
},
|
||||
},
|
||||
],
|
||||
['a'],
|
||||
);
|
||||
expect(output).toEqual([{ a: null }]);
|
||||
});
|
||||
|
||||
it('should clone objects', () => {
|
||||
const input = {
|
||||
a: { b: 5 },
|
||||
};
|
||||
const output = copyInputItems(
|
||||
[
|
||||
{
|
||||
json: input,
|
||||
},
|
||||
],
|
||||
['a'],
|
||||
);
|
||||
expect(output[0].a).toEqual(input.a);
|
||||
expect(output[0].a === input.a).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user