-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: amplitude add support for unset (#2941)
* feat: amplitude add support for unset * Update src/v0/destinations/am/transform.js Co-authored-by: Yashasvi Bajpai <[email protected]> * Update src/v0/destinations/am/transform.js Co-authored-by: Yashasvi Bajpai <[email protected]> * chore:comment addresed * Update transform.js * chore:comment addresed * chore: added docs * Update utils.js --------- Co-authored-by: Yashasvi Bajpai <[email protected]>
- Loading branch information
1 parent
ca76297
commit 429ca71
Showing
4 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
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: { | ||
Amplitude: {}, | ||
}, | ||
}; | ||
const result = getUnsetObj(message); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it("should return an empty objecty when 'message.integrations.Amplitude.fieldsToUnset' is an empty array", () => { | ||
const message = { | ||
integrations: { | ||
Amplitude: { fieldsToUnset: [] }, | ||
}, | ||
}; | ||
const result = getUnsetObj(message); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
it("should return an object with keys and values set to '-' when 'message.integrations.Amplitude.fieldsToUnset' is an array of strings", () => { | ||
const message = { | ||
integrations: { | ||
Amplitude: { fieldsToUnset: ['Unset1', 'Unset2'] }, | ||
}, | ||
}; | ||
const result = getUnsetObj(message); | ||
expect(result).toEqual({ | ||
Unset1: '-', | ||
Unset2: '-', | ||
}); | ||
}); | ||
|
||
it("should handle missing 'message' parameter", () => { | ||
const result = getUnsetObj(); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
// Should handle missing 'integrations' property in 'message' parameter | ||
it("should handle missing 'integrations' property in 'message' parameter", () => { | ||
const message = {}; | ||
const result = getUnsetObj(message); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
// Should handle missing 'Amplitude' property in 'message.integrations' parameter | ||
it("should handle missing 'Amplitude' property in 'message.integrations' parameter", () => { | ||
const message = { | ||
integrations: {}, | ||
}; | ||
const result = getUnsetObj(message); | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters