1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-11-09 17:50:52 +03:00

🐛 Fix Stripe node multiple metadata values (#2395)

This commit is contained in:
Daniel Santamaría 2021-11-04 01:44:25 +01:00 committed by GitHub
parent a3bfdd3805
commit a5805fb80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -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 {

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