Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #2523

Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing snapshot for actions-drip destination: identify action - all fields 1`] = `
Object {
"custom_fields": Object {
"testType": "sJ%o4C6Z5FWE)u^v8eTR",
},
"email": "[email protected]",
"ip_address": "251.65.124.230",
"sms_number": "sJ%o4C6Z5FWE)u^v8eTR",
"status": "sJ%o4C6Z5FWE)u^v8eTR",
"status_updated_at": "2021-02-01T00:00:00.000Z",
"tags": Object {
"testType": "sJ%o4C6Z5FWE)u^v8eTR",
},
"time_zone": "sJ%o4C6Z5FWE)u^v8eTR",
}
`;

exports[`Testing snapshot for actions-drip destination: identify action - required fields 1`] = `
Object {
"email": "[email protected]",
}
`;

exports[`Testing snapshot for actions-drip destination: track action - all fields 1`] = `
Object {
"events": Array [
Object {
"action": "X%2wvLH",
"email": "[email protected]",
"properties": Object {
"testType": "X%2wvLH",
},
},
],
}
`;

exports[`Testing snapshot for actions-drip destination: track action - required fields 1`] = `
Object {
"events": Array [
Object {
"action": "X%2wvLH",
"email": "[email protected]",
},
],
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import nock from 'nock'
import { createTestIntegration } from '@segment/actions-core'
import Definition from '../index'
import { Settings } from '../generated-types'

const testDestination = createTestIntegration(Definition)

describe('Drip', () => {
describe('testAuthentication', () => {
it('should validate authentication inputs', async () => {
nock('https://api-staging.getdrip.com').get('/v2/user').reply(200, {})

const settings: Settings = {
apiKey: 'key'
}

await expect(testDestination.testAuthentication(settings)).resolves.not.toThrowError()
})
})
})
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-drip'

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()
}
})
}
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import nock from 'nock'
import { createTestEvent, createTestIntegration } from '@segment/actions-core'
import Destination from '../../index'
import { Settings } from '../../generated-types'

const settings: Settings = { apiKey: 'key' }

const testDestination = createTestIntegration(Destination)

describe('Drip.track', () => {
it('should identify with default mappings', async () => {
nock('https://api-staging.getdrip.com').post('/v2/3977335/subscribers').reply(200, {})

const event = createTestEvent({
event: 'Custom',
traits: { email: '[email protected]' },
properties: { fizz: 'buzz' }
})

const responses = await testDestination.testAction('identify', {
settings: settings,
event: event,
useDefaultMappings: true
})

const body = {
email: '[email protected]',
ip_address: '8.8.8.8', // This could be wrong. Is this the IP address of the client, or segment?
time_zone: 'Europe/Amsterdam',
status: 'unsubscribed'
}

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].options.body).toBe(JSON.stringify(body))
})

// TODO: should identify with mappings

it('should batch identify with default mappings', async () => {
nock('https://api-staging.getdrip.com').post('/v2/3977335/subscribers/batches').reply(200, {})

const event = createTestEvent({
event: 'Custom',
traits: { email: '[email protected]' },
properties: { fizz: 'buzz' }
})

const responses = await testDestination.testBatchAction('identify', {
settings: settings,
events: [event],
useDefaultMappings: true
})

const body = {
subscribers: [
{
email: '[email protected]',
ip_address: '8.8.8.8', // This could be wrong. Is this the IP address of the client, or segment?
time_zone: 'Europe/Amsterdam',
status: 'unsubscribed'
}
]
}

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].options.body).toBe(JSON.stringify(body))
})

// TODO: should batch identify with mappings
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 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 actionSlug = 'identify'
// const destinationSlug = 'Drip'
// const seedName = `${destinationSlug}#${actionSlug}`

// describe(`Testing snapshot for ${destinationSlug}'s ${actionSlug} destination action:`, () => {
// it('required fields', async () => {
// 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('all fields', async () => {
// 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()
// }
// })
// })

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading