Skip to content

Commit

Permalink
Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam4415 committed Apr 21, 2021
1 parent bc391d5 commit fcb90b8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion integrations/PinterestTag/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class PinterestTag {
r.parentNode.insertBefore(t, r);
}
})("https://s.pinimg.com/ct/core.js");

}

handleEnhancedMatch() {
Expand Down Expand Up @@ -169,7 +170,7 @@ export default class PinterestTag {
);
if (!destinationEvent && this.userDefinedEventsMapping.length > 0) {
const userDefinedEvent = this.userDefinedEventsMapping.find(
(e) => e.pinterestEvent.toLowerCase() === event.toLowerCase()
(e) => e.rudderEvent.toLowerCase() === event.toLowerCase()
);
if (userDefinedEvent && userDefinedEvent.rudderEvent) {
return {
Expand Down
26 changes: 26 additions & 0 deletions integrations/PinterestTag/test/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,29 @@ rudderanalytics.track("Order Completed", {
},
],
});
// This event will map to Signup for Pinterest because there is a property mapping associated with it.
rudderanalytics.track("register", {
checkout_id: "12345",
order_id: "1234",
isUserAuthenticated: true, // custom properties
isDomainLocked: false, // custom properties
coupon: "ImagePro",
currency: "USD",
products: [
{
product_id: "123",
sku: "G-32",
name: "Monopoly",
price: 14,
quantity: 1,
category: "Games",
},
{
sku: "F-32-sku-value",
name: "UNO",
price: 3.45,
quantity: 2,
category: "Games",
},
],
});
29 changes: 29 additions & 0 deletions integrations/PinterestTag/test/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,32 @@ pintrk("track", "Checkout", {
isUserAuthenticated: "true",
isDomainLocked: "false",
});

pintrk(
"track",
"Signup",

{
order_id: "1234",
coupon: "ImagePro",
currency: "USD",
line_items: [
{
product_quantity: "1",
product_category: "Games",
product_price: "14",
product_name: "Monopoly",
product_id: "123",
},
{
product_quantity: "2",
product_category: "Games",
product_price: "3.45",
product_name: "UNO",
product_id: "F-32-sku-value",
},
],
isUserAuthenticated: "true",
isDomainLocked: "false",
}
);

0 comments on commit fcb90b8

Please sign in to comment.