-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating snapshot tests braze moengage and trackey
- Loading branch information
1 parent
a2172b9
commit 4f3febd
Showing
9 changed files
with
269 additions
and
99 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
115 changes: 69 additions & 46 deletions
115
...stination-actions/src/destinations/moengage/__tests__/__snapshots__/snapshot.test.ts.snap
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 |
---|---|---|
@@ -1,50 +1,73 @@ | ||
import nock from 'nock' | ||
import { createTestEvent, createTestIntegration } from '@segment/actions-core' | ||
import Destination from '../../index' | ||
import { getEndpointByRegion } from '../../regional-endpoints' | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
const testDestination = createTestIntegration(Destination) | ||
const MOENGAGE_API_ID = 'SOME_APP_ID' | ||
const MOENGAGE_API_KEY = 'SOME_APP_KEY' | ||
const MOENGAGE_REGION = 'SOME_REGION' | ||
exports[`Testing snapshot for actions-moengage destination: identifyUser action - all fields 1`] = ` | ||
Object { | ||
"anonymous_id": "z(%@QRCz7h$8M)#]", | ||
"context": Object { | ||
"app": Object { | ||
"version": "z(%@QRCz7h$8M)#]", | ||
}, | ||
"library": Object { | ||
"version": "z(%@QRCz7h$8M)#]", | ||
}, | ||
"os": Object { | ||
"name": "z(%@QRCz7h$8M)#]", | ||
}, | ||
}, | ||
"timestamp": "2021-02-01T00:00:00.000Z", | ||
"traits": Object { | ||
"testType": "z(%@QRCz7h$8M)#]", | ||
}, | ||
"type": "z(%@QRCz7h$8M)#]", | ||
"update_existing_only": false, | ||
"user_id": "z(%@QRCz7h$8M)#]", | ||
} | ||
`; | ||
|
||
const endpoint = getEndpointByRegion() | ||
exports[`Testing snapshot for actions-moengage destination: identifyUser action - required fields 1`] = ` | ||
Object { | ||
"context": Object { | ||
"app": Object {}, | ||
"library": Object {}, | ||
"os": Object {}, | ||
}, | ||
"type": "z(%@QRCz7h$8M)#]", | ||
"update_existing_only": false, | ||
} | ||
`; | ||
|
||
describe('ActionsMoengage.identifyUser', () => { | ||
it('should validate action fields', async () => { | ||
const event = createTestEvent({ traits: { name: 'abc' } }) | ||
exports[`Testing snapshot for actions-moengage destination: trackEvent action - all fields 1`] = ` | ||
Object { | ||
"anonymous_id": "E@t!q#n(^u", | ||
"context": Object { | ||
"app": Object { | ||
"version": "E@t!q#n(^u", | ||
}, | ||
"library": Object { | ||
"version": "E@t!q#n(^u", | ||
}, | ||
"os": Object { | ||
"name": "E@t!q#n(^u", | ||
}, | ||
}, | ||
"event": "E@t!q#n(^u", | ||
"properties": Object { | ||
"testType": "E@t!q#n(^u", | ||
}, | ||
"timestamp": "2021-02-01T00:00:00.000Z", | ||
"type": "E@t!q#n(^u", | ||
"user_id": "E@t!q#n(^u", | ||
} | ||
`; | ||
|
||
nock(`${endpoint}`).post(`/v1/integrations/segment?appId=${MOENGAGE_API_ID}`).reply(200, {}) | ||
|
||
const responses = await testDestination.testAction('identifyUser', { | ||
event, | ||
useDefaultMappings: true, | ||
settings: { | ||
api_id: MOENGAGE_API_ID, | ||
api_key: MOENGAGE_API_KEY, | ||
region: MOENGAGE_REGION | ||
} | ||
}) | ||
|
||
expect(responses.length).toBe(1) | ||
expect(responses[0].status).toBe(200) | ||
expect(responses[0].data).toMatchObject({}) | ||
expect(responses[0].options.body).toBe( | ||
`{"type":"track","user_id":"user1234","traits":{"name":"abc"},"context":{"app":{},"os":{},"library":{"version":"2.11.1"}},"anonymous_id":"${event.anonymousId}","timestamp":"${event.timestamp}","update_existing_only":false}` | ||
) | ||
}) | ||
|
||
it('should require api_id and api_key', async () => { | ||
const event = createTestEvent() | ||
nock(`${endpoint}`).post(`/v1/integrations/segment?appId=${MOENGAGE_API_ID}`).reply(200, {}) | ||
|
||
try { | ||
await testDestination.testAction('identifyUser', { | ||
event, | ||
useDefaultMappings: true | ||
}) | ||
} catch (e) { | ||
expect(e.message).toBe('Missing API ID or API KEY') | ||
} | ||
}) | ||
}) | ||
exports[`Testing snapshot for actions-moengage destination: trackEvent action - required fields 1`] = ` | ||
Object { | ||
"context": Object { | ||
"app": Object {}, | ||
"library": Object {}, | ||
"os": Object {}, | ||
}, | ||
"event": "E@t!q#n(^u", | ||
"type": "E@t!q#n(^u", | ||
} | ||
`; |
54 changes: 27 additions & 27 deletions
54
...estination-actions/src/destinations/trackey/__tests__/__snapshots__/snapshot.test.ts.snap
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 |
---|---|---|
@@ -1,62 +1,62 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing snapshot for actions-trackey destination: identify action - all fields 1`] = ` | ||
exports[`Testing snapshot for actions-trackey destination: group action - all fields 1`] = ` | ||
Object { | ||
"messageId": "4lC*xBPj6Zf^iE3J1PF", | ||
"timestamp": "4lC*xBPj6Zf^iE3J1PF", | ||
"groupId": "^Vvf$jtvC", | ||
"messageId": "^Vvf$jtvC", | ||
"timestamp": "^Vvf$jtvC", | ||
"traits": Object { | ||
"testType": "4lC*xBPj6Zf^iE3J1PF", | ||
"testType": "^Vvf$jtvC", | ||
}, | ||
"userId": "4lC*xBPj6Zf^iE3J1PF", | ||
"userId": "^Vvf$jtvC", | ||
} | ||
`; | ||
|
||
exports[`Testing snapshot for actions-trackey destination: identify action - required fields 1`] = ` | ||
exports[`Testing snapshot for actions-trackey destination: group action - required fields 1`] = ` | ||
Object { | ||
"timestamp": "4lC*xBPj6Zf^iE3J1PF", | ||
"userId": "4lC*xBPj6Zf^iE3J1PF", | ||
"groupId": "^Vvf$jtvC", | ||
"timestamp": "^Vvf$jtvC", | ||
"userId": "^Vvf$jtvC", | ||
} | ||
`; | ||
|
||
exports[`Testing snapshot for actions-trackey destination: group action - all fields 1`] = ` | ||
exports[`Testing snapshot for actions-trackey destination: identify action - all fields 1`] = ` | ||
Object { | ||
"groupId": "dv8xxzqiX16YI!L#st", | ||
"messageId": "dv8xxzqiX16YI!L#st", | ||
"timestamp": "dv8xxzqiX16YI!L#st", | ||
"messageId": "6aniX&1", | ||
"timestamp": "6aniX&1", | ||
"traits": Object { | ||
"testType": "dv8xxzqiX16YI!L#st", | ||
"testType": "6aniX&1", | ||
}, | ||
"userId": "dv8xxzqiX16YI!L#st", | ||
"userId": "6aniX&1", | ||
} | ||
`; | ||
|
||
exports[`Testing snapshot for actions-trackey destination: group action - required fields 1`] = ` | ||
exports[`Testing snapshot for actions-trackey destination: identify action - required fields 1`] = ` | ||
Object { | ||
"groupId": "dv8xxzqiX16YI!L#st", | ||
"timestamp": "dv8xxzqiX16YI!L#st", | ||
"userId": "dv8xxzqiX16YI!L#st", | ||
"timestamp": "6aniX&1", | ||
"userId": "6aniX&1", | ||
} | ||
`; | ||
|
||
exports[`Testing snapshot for actions-trackey destination: track action - all fields 1`] = ` | ||
Object { | ||
"event": "qnx]3%$)][Qxz", | ||
"event": "eT[K8ft@uBryp", | ||
"groupId": Object { | ||
"testType": "qnx]3%$)][Qxz", | ||
"testType": "eT[K8ft@uBryp", | ||
}, | ||
"messageId": "qnx]3%$)][Qxz", | ||
"messageId": "eT[K8ft@uBryp", | ||
"properties": Object { | ||
"testType": "qnx]3%$)][Qxz", | ||
"testType": "eT[K8ft@uBryp", | ||
}, | ||
"timestamp": "qnx]3%$)][Qxz", | ||
"userId": "qnx]3%$)][Qxz", | ||
"timestamp": "eT[K8ft@uBryp", | ||
"userId": "eT[K8ft@uBryp", | ||
} | ||
`; | ||
|
||
exports[`Testing snapshot for actions-trackey destination: track action - required fields 1`] = ` | ||
Object { | ||
"event": "qnx]3%$)][Qxz", | ||
"timestamp": "qnx]3%$)][Qxz", | ||
"userId": "qnx]3%$)][Qxz", | ||
"event": "eT[K8ft@uBryp", | ||
"timestamp": "eT[K8ft@uBryp", | ||
"userId": "eT[K8ft@uBryp", | ||
} | ||
`; |
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
Oops, something went wrong.