Skip to content

Commit

Permalink
chore: formatting updates - 3
Browse files Browse the repository at this point in the history
Signed-off-by: Sai Sankeerth <[email protected]>
  • Loading branch information
Sai Sankeerth committed Feb 16, 2024
1 parent 9df9f07 commit 0b7238b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
16 changes: 9 additions & 7 deletions src/v0/destinations/am/util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ describe('getUnsetObj', () => {
});
});


describe('validateEventType', () => {

it('should validate event type when it is valid with only page name given', () => {
expect(() => {
validateEventType('Home Page');
Expand All @@ -77,21 +75,25 @@ describe('validateEventType', () => {
it('should throw an error when event type is null', () => {
expect(() => {
validateEventType(null);
}).toThrow('Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`');
}).toThrow(
'Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`',
);
});

it('should throw an error when event type is undefined', () => {
expect(() => {
validateEventType(undefined);
}).toThrow('Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`');
}).toThrow(
'Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`',
);
});

// Function receives an empty string as event type
it('should throw an error when event type is an empty string', () => {
expect(() => {
validateEventType('');
}).toThrow('Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`');
}).toThrow(
'Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`',
);
});

});

16 changes: 8 additions & 8 deletions src/v0/destinations/am/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ const getUnsetObj = (message) => {
};

/**
* Check for evType as in some cases, like when the page name is absent,
* Check for evType as in some cases, like when the page name is absent,
* either the template depends only on the event.name or there is no template provided by user
* @param {*} evType
* @param {*} evType
*/
const validateEventType = (evType) => {
if (!isDefinedAndNotNull(evType) || (typeof evType === "string" && evType.length ===0)) {
throw new InstrumentationError(
'Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`',
);
}
if (!isDefinedAndNotNull(evType) || (typeof evType === 'string' && evType.length === 0)) {
throw new InstrumentationError(
'Event type is missing. Please send it under `event.type`. For page/screen events, send it under `event.name`',
);
}
};
module.exports = {
getOSName,
Expand All @@ -131,5 +131,5 @@ module.exports = {
getBrand,
getEventId,
getUnsetObj,
validateEventType
validateEventType,
};
22 changes: 11 additions & 11 deletions src/v0/destinations/tiktok_ads_offline_events/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ const CONFIG_CATEGORIES = {
const PARTNER_NAME = 'RudderStack';

const EVENT_NAME_MAPPING = {
'addpaymentinfo': 'AddPaymentInfo',
'addtocart': 'AddToCart',
'addtowishlist': 'AddToWishlist',
addpaymentinfo: 'AddPaymentInfo',
addtocart: 'AddToCart',
addtowishlist: 'AddToWishlist',
'checkout started': 'InitiateCheckout',
'checkout step completed': 'CompletePayment',
'clickbutton': 'ClickButton',
'completeregistration': 'CompleteRegistration',
'contact': 'Contact',
'download': 'Download',
clickbutton: 'ClickButton',
completeregistration: 'CompleteRegistration',
contact: 'Contact',
download: 'Download',
'order completed': 'PlaceAnOrder',
'payment info entered': 'AddPaymentInfo',
'product added': 'AddToCart',
'product added to wishlist': 'AddToWishlist',
'search': 'Search',
'submitform': 'SubmitForm',
'subscribe': 'Subscribe',
'viewcontent': 'ViewContent',
search: 'Search',
submitform: 'SubmitForm',
subscribe: 'Subscribe',
viewcontent: 'ViewContent',
};
const MAPPING_CONFIG = getMappingConfig(CONFIG_CATEGORIES, __dirname);

Expand Down

0 comments on commit 0b7238b

Please sign in to comment.