Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export const destination: BrowserDestinationDefinition<Settings, BrazeDestinatio
...expectedConfig
} = settings

console.log({ ...expectedConfig })
const version = sdkVersion ?? defaultVersion

resetUserCache()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing snapshot for actions-ms-bing-capi destination: pageLoad action - all fields 1`] = `
Object {
"data": Array [
Object {
"eventId": "PhGSU",
"eventName": "PhGSU",
"eventSourceUrl": "PhGSU",
"eventTime": "PhGSU",
"eventType": "pageLoad",
"keywords": "PhGSU",
"pageLoadId": "PhGSU",
"pageTitle": "PhGSU",
"referrerUrl": "PhGSU",
"userData": Object {},
},
],
}
`;

exports[`Testing snapshot for actions-ms-bing-capi destination: pageLoad action - required fields 1`] = `
Object {
"data": Array [
Object {
"eventSourceUrl": "PhGSU",
"eventTime": "PhGSU",
"eventType": "pageLoad",
"userData": Object {},
},
],
}
`;

exports[`Testing snapshot for actions-ms-bing-capi destination: sendEvent action - all fields 1`] = `
Object {
"data": Array [
Object {
"eventId": "I!xun!sL*a3e9mQ",
"eventName": "I!xun!sL*a3e9mQ",
"eventSourceUrl": "I!xun!sL*a3e9mQ",
"eventTime": "I!xun!sL*a3e9mQ",
"eventType": "custom",
"keywords": "I!xun!sL*a3e9mQ",
"pageLoadId": "I!xun!sL*a3e9mQ",
"pageTitle": "I!xun!sL*a3e9mQ",
"referrerUrl": "I!xun!sL*a3e9mQ",
"userData": Object {},
},
],
}
`;

exports[`Testing snapshot for actions-ms-bing-capi destination: sendEvent action - required fields 1`] = `
Object {
"data": Array [
Object {
"eventSourceUrl": "I!xun!sL*a3e9mQ",
"eventTime": "I!xun!sL*a3e9mQ",
"eventType": "custom",
"userData": Object {},
},
],
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { createTestEvent, createTestIntegration } from '@segment/actions-core'
import { generateTestData } from '../../../lib/test-data'
import destination from '../index'
import nock from 'nock'

const testDestination = createTestIntegration(destination)
const destinationSlug = 'actions-ms-bing-capi'

describe(`Testing snapshot for ${destinationSlug} destination:`, () => {
for (const actionSlug in destination.actions) {
it(`${actionSlug} action - required fields`, async () => {
const seedName = `${destinationSlug}#${actionSlug}`
const action = destination.actions[actionSlug]
const [eventData, settingsData] = generateTestData(seedName, destination, action, true)

nock(/.*/).persist().get(/.*/).reply(200)
nock(/.*/).persist().post(/.*/).reply(200)
nock(/.*/).persist().put(/.*/).reply(200)

const event = createTestEvent({
properties: eventData
})

const responses = await testDestination.testAction(actionSlug, {
event: event,
mapping: event.properties,
settings: settingsData,
auth: undefined
})

const request = responses[0].request
const rawBody = await request.text()

try {
const json = JSON.parse(rawBody)
expect(json).toMatchSnapshot()
return
} catch (err) {
expect(rawBody).toMatchSnapshot()
}

expect(request.headers).toMatchSnapshot()
})

it(`${actionSlug} action - all fields`, async () => {
const seedName = `${destinationSlug}#${actionSlug}`
const action = destination.actions[actionSlug]
const [eventData, settingsData] = generateTestData(seedName, destination, action, false)

nock(/.*/).persist().get(/.*/).reply(200)
nock(/.*/).persist().post(/.*/).reply(200)
nock(/.*/).persist().put(/.*/).reply(200)

const event = createTestEvent({
properties: eventData
})

const responses = await testDestination.testAction(actionSlug, {
event: event,
mapping: event.properties,
settings: settingsData,
auth: undefined
})

const request = responses[0].request
const rawBody = await request.text()

try {
const json = JSON.parse(rawBody)
expect(json).toMatchSnapshot()
return
} catch (err) {
expect(rawBody).toMatchSnapshot()
}
})
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
export const API_URL = `https://capi.uet.microsoft.com/v1/`

export const CURRENCY_ISO_CODES = new Set([
'AED',
'AFN',
'ALL',
'AMD',
'ANG',
'AOA',
'ARS',
'AUD',
'AWG',
'AZN',
'BAM',
'BBD',
'BDT',
'BGN',
'BHD',
'BIF',
'BMD',
'BND',
'BOB',
'BOV',
'BRL',
'BSD',
'BTN',
'BWP',
'BYN',
'BZD',
'CAD',
'CDF',
'CHE',
'CHF',
'CHW',
'CLF',
'CLP',
'CNY',
'COP',
'COU',
'CRC',
'CUC',
'CUP',
'CVE',
'CZK',
'DJF',
'DKK',
'DOP',
'DZD',
'EGP',
'ERN',
'ETB',
'EUR',
'FJD',
'FKP',
'GBP',
'GEL',
'GHS',
'GIP',
'GMD',
'GNF',
'GTQ',
'GYD',
'HKD',
'HNL',
'HRK',
'HTG',
'HUF',
'IDR',
'ILS',
'INR',
'IQD',
'IRR',
'ISK',
'JMD',
'JOD',
'JPY',
'KES',
'KGS',
'KHR',
'KMF',
'KPW',
'KRW',
'KWD',
'KYD',
'KZT',
'LAK',
'LBP',
'LKR',
'LRD',
'LSL',
'LYD',
'MAD',
'MDL',
'MGA',
'MKD',
'MMK',
'MNT',
'MOP',
'MRU',
'MUR',
'MVR',
'MWK',
'MXN',
'MXV',
'MYR',
'MZN',
'NAD',
'NGN',
'NIO',
'NOK',
'NPR',
'NZD',
'OMR',
'PAB',
'PEN',
'PGK',
'PHP',
'PKR',
'PLN',
'PYG',
'QAR',
'RON',
'RSD',
'RUB',
'RWF',
'SAR',
'SBD',
'SCR',
'SDG',
'SEK',
'SGD',
'SHP',
'SLL',
'SOS',
'SRD',
'SSP',
'STN',
'SVC',
'SYP',
'SZL',
'THB',
'TJS',
'TMT',
'TND',
'TOP',
'TRY',
'TTD',
'TWD',
'TZS',
'UAH',
'UGX',
'USD',
'USN',
'UYI',
'UYU',
'UYW',
'UZS',
'VES',
'VND',
'VUV',
'WST',
'XAF',
'XAG',
'XAU',
'XBA',
'XBB',
'XBC',
'XBD',
'XCD',
'XDR',
'XOF',
'XPD',
'XPF',
'XPT',
'XSU',
'XTS',
'XUA',
'XXX',
'YER',
'ZAR',
'ZMW',
'ZWC'
])
Loading
Loading