mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
🐛 Fix Stripe node multiple metadata values (#2395)
This commit is contained in:
parent
a3bfdd3805
commit
a5805fb80b
|
@ -102,10 +102,10 @@ export function adjustMetadata(
|
|||
) {
|
||||
if (!fields.metadata || isEmpty(fields.metadata)) return fields;
|
||||
|
||||
let adjustedMetadata = {};
|
||||
const adjustedMetadata: Record<string, string> = {};
|
||||
|
||||
fields.metadata.metadataProperties.forEach(pair => {
|
||||
adjustedMetadata = { ...adjustedMetadata, ...pair };
|
||||
adjustedMetadata[pair.key] = pair.value;
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
30
packages/nodes-base/test/nodes/Stripe/helpers.test.js
Normal file
30
packages/nodes-base/test/nodes/Stripe/helpers.test.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const helpers = require("../../../nodes/Stripe/helpers");
|
||||
|
||||
describe('adjustMetadata', () => {
|
||||
it('it should adjust multiple metadata values', async () => {
|
||||
const additionalFieldsValues = {
|
||||
metadata: {
|
||||
metadataProperties: [
|
||||
{
|
||||
key: "keyA",
|
||||
value: "valueA"
|
||||
},
|
||||
{
|
||||
key: "keyB",
|
||||
value: "valueB"
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
const adjustedMetadata = helpers.adjustMetadata(additionalFieldsValues)
|
||||
|
||||
const expectedAdjustedMetadata = {
|
||||
metadata: {
|
||||
keyA: "valueA",
|
||||
keyB: "valueB"
|
||||
}
|
||||
}
|
||||
expect(adjustedMetadata).toStrictEqual(expectedAdjustedMetadata)
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue