-
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.
- Loading branch information
1 parent
178aeba
commit 2ba43f4
Showing
9 changed files
with
1,183 additions
and
13 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
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,38 @@ | ||
const { validateTrackSMSCampaignPayload } = require('./utils'); | ||
|
||
describe('validateTrackSMSCampaignPayload', () => { | ||
// payload with all required fields defined and non-empty does not throw an error | ||
it('should not throw an error when all required fields are defined and non-empty', () => { | ||
const payload = { | ||
body: 'Test message', | ||
name: 'Test Campaign', | ||
list_id: '12345', | ||
from: 'TestSender', | ||
}; | ||
expect(() => validateTrackSMSCampaignPayload(payload)).not.toThrow(); | ||
}); | ||
|
||
// payload with body field missing throws an error | ||
it('should throw an error when body field is missing', () => { | ||
const payload = { | ||
name: 'Test Campaign', | ||
list_id: '12345', | ||
from: 'TestSender', | ||
}; | ||
expect(() => validateTrackSMSCampaignPayload(payload)).toThrow( | ||
'All of contact list Id, name, body and from are required to trigger an sms campaign', | ||
); | ||
}); | ||
|
||
it('should throw an error when from field is empty string', () => { | ||
const payload = { | ||
name: 'Test Campaign', | ||
list_id: '12345', | ||
from: '', | ||
body: 'Test message', | ||
}; | ||
expect(() => validateTrackSMSCampaignPayload(payload)).toThrow( | ||
'All of contact list Id, name, body and from are required to trigger an sms campaign', | ||
); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
test/integrations/destinations/clicksend/commonConfig.ts
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,103 @@ | ||
export const destination = { | ||
ID: 'random_id', | ||
Name: 'clicksend', | ||
DestinationDefinition: { | ||
Config: { | ||
cdkV2Enabled: true, | ||
}, | ||
}, | ||
Config: { | ||
clicksendUsername: 'dummy', | ||
clicksendPassword: 'dummy', | ||
defaultCampaignScheduleUnit: 'day', | ||
defaultCampaignSchedule: '2', | ||
defaultSource: 'php', | ||
defaultSenderEmail: '[email protected]', | ||
defaultSenderPhoneNumber: '+919XXXXXXXX8', | ||
oneTrustCookieCategories: [ | ||
{ | ||
oneTrustCookieCategory: 'Marketing', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const metadata = { | ||
destinationId: 'dummyDestId', | ||
}; | ||
export const commonProperties = { | ||
name: 'new campaign', | ||
body: 'abcd', | ||
from: '[email protected]', | ||
from_email: '[email protected]', | ||
custom_string: 'test string', | ||
}; | ||
export const traitsWithIdentifiers = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
phone: '+9182XXXX068', | ||
email: '[email protected]', | ||
address: { city: 'New York', country: 'USA', pinCode: '123456' }, | ||
}; | ||
export const traitsWithoutIdenfiers = { | ||
firstName: 'John', | ||
lastName: 'Doe', | ||
address: { city: 'New York', country: 'USA', pinCode: '123456' }, | ||
}; | ||
export const contextWithoutScheduleAndWithContactId = { | ||
externalId: [{ type: 'CLICKSEND_CONTACT_LIST_ID', id: '123345' }], | ||
traitsWithoutIdenfiers, | ||
}; | ||
export const commonInput = { | ||
anonymousId: 'anon_123', | ||
messageId: 'dummy_msg_id', | ||
contextWithoutScheduleAndWithContactId, | ||
channel: 'web', | ||
integrations: { | ||
All: true, | ||
}, | ||
originalTimestamp: '2021-01-25T15:32:56.409Z', | ||
}; | ||
|
||
export const commonOutput = { | ||
anonymousId: 'anon_123', | ||
messageId: 'dummy_msg_id', | ||
contextWithoutScheduleAndWithContactId, | ||
channel: 'web', | ||
originalTimestamp: '2021-01-25T15:32:56.409Z', | ||
}; | ||
|
||
export const SMS_SEND_ENDPOINT = 'https://rest.clicksend.com/v3/sms/send'; | ||
export const SMS_CAMPAIGN_ENDPOINT = 'https://rest.clicksend.com/v3/sms-campaigns/send'; | ||
export const COMMON_CONTACT_DOMAIN = 'https://rest.clicksend.com/v3/lists'; | ||
export const routerInstrumentationErrorStatTags = { | ||
destType: 'CLICKSEND', | ||
errorCategory: 'dataValidation', | ||
errorType: 'instrumentation', | ||
feature: 'router', | ||
implementation: 'cdkV2', | ||
module: 'destination', | ||
}; | ||
export const commonIdentifyOutput = { | ||
address_line_1: '{"city":"New York","country":"USA","pinCode":"123456"}', | ||
address_line_2: '{"city":"New York","country":"USA","pinCode":"123456"}', | ||
city: 'New York', | ||
email: '[email protected]', | ||
first_name: 'John', | ||
last_name: 'Doe', | ||
phone_number: '+9182XXXX068', | ||
}; | ||
export const processInstrumentationErrorStatTags = { | ||
destType: 'CLICKSEND', | ||
errorCategory: 'dataValidation', | ||
errorType: 'instrumentation', | ||
feature: 'processor', | ||
implementation: 'cdkV2', | ||
module: 'destination', | ||
destinationId: 'dummyDestId', | ||
}; | ||
|
||
export const commonHeader = { | ||
Authorization: 'Basic ZHVtbXk6ZHVtbXk=', | ||
'Content-Type': 'application/json', | ||
}; |
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,3 @@ | ||
import { track } from './track'; | ||
import { identify } from './identify'; | ||
export const data = [...identify, ...track]; |
Oops, something went wrong.