refactor(core): Move copyInputItems to node helpers (no-changelog) (#7299)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-10-06 16:25:58 +02:00
committed by GitHub
parent 34bda535e6
commit 597669aa62
9 changed files with 84 additions and 95 deletions

View File

@@ -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);
});
});
});