Skip to content

Commit

Permalink
fix: review comment addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Aug 19, 2024
1 parent fc92084 commit e91a821
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/v0/destinations/attentive_tag/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
const {
getDestinationItemProperties,
getExternalIdentifiersMapping,
getPropertiesKeyValidation,
arePropertiesValid,
validateTimestamp,
} = require('./util');
const { JSON_MIME_TYPE } = require('../../util/constant');
Expand Down Expand Up @@ -137,7 +137,7 @@ const trackResponseBuilder = (message, { Config }) => {
payload = constructPayload(message, mappingConfig[ConfigCategory.TRACK.name]);
endpoint = ConfigCategory.TRACK.endpoint;
payload.type = get(message, 'event');
if (!getPropertiesKeyValidation(payload.properties)) {
if (!arePropertiesValid(payload.properties)) {
throw new InstrumentationError(
'[Attentive Tag]:The event name contains characters which is not allowed',
);
Expand Down
4 changes: 2 additions & 2 deletions src/v0/destinations/attentive_tag/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { mappingConfig, ConfigCategory } = require('./config');
* @param {*} payload
* @returns
*/
const getPropertiesKeyValidation = (properties) => {
const arePropertiesValid = (properties) => {
if (!isDefinedAndNotNullAndNotEmpty(properties)) {
return true;
}
Expand Down Expand Up @@ -141,6 +141,6 @@ const getDestinationItemProperties = (message, isItemsRequired) => {
module.exports = {
getDestinationItemProperties,
getExternalIdentifiersMapping,
getPropertiesKeyValidation,
arePropertiesValid,
validateTimestamp,
};
16 changes: 8 additions & 8 deletions src/v0/destinations/attentive_tag/util.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const { getPropertiesKeyValidation } = require('./util');
const { arePropertiesValid } = require('./util');

describe('getPropertiesKeyValidation', () => {
describe('arePropertiesValid', () => {
// returns true for valid properties object with no special characters in keys
it('should return true when properties object has no special characters in keys', () => {
const properties = { key1: 'value1', key2: 'value2' };
const result = getPropertiesKeyValidation(properties);
const result = arePropertiesValid(properties);
expect(result).toBe(true);
});

// returns true for null properties input
it('should return true when properties input is null', () => {
const properties = null;
const result = getPropertiesKeyValidation(properties);
const result = arePropertiesValid(properties);
expect(result).toBe(true);
});

Expand All @@ -22,24 +22,24 @@ describe('getPropertiesKeyValidation', () => {
'key,2': 'value2',
key3: 'value3',
};
expect(getPropertiesKeyValidation(properties)).toBe(false);
expect(arePropertiesValid(properties)).toBe(false);
});

// returns true for empty properties object
it('should return true for empty properties object', () => {
const properties = {};
expect(getPropertiesKeyValidation(properties)).toBe(true);
expect(arePropertiesValid(properties)).toBe(true);
});

// returns true for undefined properties input
it('should return true for undefined properties input', () => {
const result = getPropertiesKeyValidation(undefined);
const result = arePropertiesValid(undefined);
expect(result).toBe(true);
});

// returns true for empty string properties input
it('should return true for empty string properties input', () => {
const result = getPropertiesKeyValidation('');
const result = arePropertiesValid('');
expect(result).toBe(true);
});
});

0 comments on commit e91a821

Please sign in to comment.