Skip to content

Commit

Permalink
chore:comment addresed
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Dec 22, 2023
1 parent 11da01f commit 55d5fd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/v0/destinations/am/util.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
const { getUnsetObj } = require('./utils');

describe('getUnsetObj', () => {
it("should return undefined when 'message.integrations.Amplitude.fieldsToUnset' is not array", () => {
const message = {
integrations: {
Amplitude: { fieldsToUnset: 'field_name' },
},
};
const result = getUnsetObj(message);
expect(result).toBeUndefined();
});
it("should return undefined when 'message.integrations.Amplitude.fieldsToUnset' is undefined", () => {
const message = {
integrations: {
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/am/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getEventId = (payload, sourceKey) => {
const getUnsetObj = (message) => {
const fieldsToUnset = get(message, 'integrations.Amplitude.fieldsToUnset');
let unsetObject;
if (fieldsToUnset) {
if (fieldsToUnset && Array.isArray(fieldsToUnset)) {
unsetObject = Object.fromEntries(fieldsToUnset.map((field) => [field, '-']));
}

Expand Down

0 comments on commit 55d5fd8

Please sign in to comment.