Skip to content

Commit

Permalink
fix: editing logic + test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Mar 22, 2024
1 parent 16095ad commit 1d37099
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/linkedin_ads/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const calculateConversionObject = (message) => {
};
const conversionObject = {
currencyCode: properties.currency || 'USD',
amount: calculateAmount() || 0,
amount: `${calculateAmount() || 0}`,
};
return conversionObject;
};
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/v2/destinations/linkedin_ads/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ describe('calculateConversionObject', () => {
it('should return a conversion object with currency code "USD" and amount 0 when message properties are empty', () => {
const message = { properties: {} };
const conversionObject = calculateConversionObject(message);
expect(conversionObject).toEqual({ currencyCode: 'USD', amount: 0 });
expect(conversionObject).toEqual({ currencyCode: 'USD', amount: '0' });
});

// Returns a conversion object with currency code 'USD' and amount 0 when message properties price is defined but quantity is 0
it('should return a conversion object with currency code "USD" and amount 0 when message properties price is defined but quantity is 0', () => {
const message = { properties: { price: 10, quantity: 0 } };
const conversionObject = calculateConversionObject(message);
expect(conversionObject).toEqual({ currencyCode: 'USD', amount: 0 });
expect(conversionObject).toEqual({ currencyCode: 'USD', amount: '0' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const element = {
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
Expand Down Expand Up @@ -89,8 +89,8 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'linkedin_ads_v1_scenario_1',
name: 'linkedin_ads',
description: 'app event fails due to revoked access token error',
successCriteria: 'Should return 500 with revoked access token error',
description: 'Event fails due to wrong process followed while creating a conversion',
successCriteria: 'Should return 400 and aborted',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
Expand Down Expand Up @@ -149,8 +149,8 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'linkedin_ads_v1_scenario_1',
name: 'linkedin_ads',
description: 'app event fails due to revoked access token error',
successCriteria: 'Should return 500 with revoked access token error',
description: 'Event fails due to wrong format payload sent to linkedin',
successCriteria: 'Should return 400 with appropriate reason of failure',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { testScenariosForV1API, statTags as baseStatTags } from './business';
import { oauthScenariosV1 } from './oauth';

export const data = [
...testScenariosForV1API,
// ...oauthScenariosV1,
];
export const data = [...testScenariosForV1API, ...oauthScenariosV1];
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const testJSONData = {
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
Expand Down Expand Up @@ -122,8 +122,8 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
{
id: 'linkedin_ads_v1_scenario_1',
name: 'linkedin_ads',
description: 'app event fails due to revoked access token error',
successCriteria: 'Should return 500 with revoked access token error',
description: 'app event fails due to invalid access token error',
successCriteria: 'Should return 500 with invalid access token error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
Expand Down Expand Up @@ -183,8 +183,8 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
{
id: 'linkedin_ads_v1_scenario_1',
name: 'linkedin_ads',
description: 'app event fails due to revoked access token error',
successCriteria: 'Should return 500 with revoked access token error',
description: 'success case',
successCriteria: 'Should return 200 response',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
Expand Down
2 changes: 1 addition & 1 deletion test/integrations/destinations/linkedin_ads/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const element = {
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const configLevelFeaturesTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: 'a80f82be-9bdc-4a9f-b2a5-15621ee41df8',
Expand Down Expand Up @@ -195,7 +195,7 @@ export const configLevelFeaturesTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down Expand Up @@ -216,7 +216,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:1234567',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand All @@ -234,7 +234,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:34567',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down Expand Up @@ -328,7 +328,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down Expand Up @@ -488,7 +488,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 800,
amount: '800',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down Expand Up @@ -580,7 +580,7 @@ export const trackTestData: ProcessorTestData[] = [
conversion: 'urn:lla:llaPartnerConversion:23456',
conversionHappenedAt: 1697241600000,
conversionValue: {
amount: 0,
amount: '0',
currencyCode: 'USD',
},
eventId: '12345',
Expand Down
8 changes: 4 additions & 4 deletions test/integrations/destinations/linkedin_ads/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export const data = [
eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9',
conversionValue: {
currencyCode: 'USD',
amount: 50,
amount: '50',
},
user: {
userIds: [
Expand All @@ -369,7 +369,7 @@ export const data = [
eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9',
conversionValue: {
currencyCode: 'USD',
amount: 50,
amount: '50',
},
user: {
userIds: [
Expand All @@ -391,7 +391,7 @@ export const data = [
eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9',
conversionValue: {
currencyCode: 'USD',
amount: 50,
amount: '50',
},
user: {
userIds: [
Expand All @@ -413,7 +413,7 @@ export const data = [
eventId: '7208bbb6-2c4e-45bb-bf5b-ad426f3593e9',
conversionValue: {
currencyCode: 'USD',
amount: 50,
amount: '50',
},
user: {
userIds: [
Expand Down

0 comments on commit 1d37099

Please sign in to comment.