-
Notifications
You must be signed in to change notification settings - Fork 243
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
9743b63
commit 211d60c
Showing
2 changed files
with
70 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,15 @@ describe('MultiStatus', () => { | |
externalId: 'test-external-id' | ||
} | ||
}), | ||
// Valid Event | ||
createTestEvent({ | ||
type: 'identify', | ||
receivedAt, | ||
traits: { | ||
name: 'Example User Two', | ||
email: '[email protected]' | ||
} | ||
}), | ||
// Event without any user identifier | ||
createTestEvent({ | ||
type: 'identify', | ||
|
@@ -68,11 +77,17 @@ describe('MultiStatus', () => { | |
body: 'success' | ||
}) | ||
|
||
// The third event fails as pre-request validation fails for not having a valid user identifier | ||
// The second event doesn't fail as there is no error reported by Braze API | ||
expect(response[1]).toMatchObject({ | ||
status: 200, | ||
body: 'success' | ||
}) | ||
|
||
// The third event fails as pre-request validation fails for not having a valid user identifier | ||
expect(response[2]).toMatchObject({ | ||
status: 400, | ||
errortype: 'PAYLOAD_VALIDATION_FAILED', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.', | ||
errorreporter: 'DESTINATION' | ||
}) | ||
}) | ||
|
@@ -201,6 +216,9 @@ describe('MultiStatus', () => { | |
describe('trackPurchase', () => { | ||
const mapping = { | ||
time: receivedAt, | ||
email: { | ||
'@path': '$.properties.email' | ||
}, | ||
external_id: { | ||
'@path': '$.properties.externalId' | ||
}, | ||
|
@@ -236,6 +254,28 @@ describe('MultiStatus', () => { | |
] | ||
} | ||
}), | ||
createTestEvent({ | ||
event: 'Order Completed', | ||
type: 'track', | ||
receivedAt, | ||
properties: { | ||
email: '[email protected]', | ||
products: [ | ||
{ | ||
product_id: 'test-product-id', | ||
currency: 'USD', | ||
price: 99.99, | ||
quantity: 1 | ||
}, | ||
{ | ||
product_id: 'test-product-id', | ||
currency: 'USD', | ||
price: 99.99, | ||
quantity: 1 | ||
} | ||
] | ||
} | ||
}), | ||
// Event with no product | ||
createTestEvent({ | ||
event: 'Order Completed', | ||
|
@@ -276,19 +316,24 @@ describe('MultiStatus', () => { | |
body: 'success' | ||
}) | ||
|
||
// The second event fails as it doesn't have any products | ||
expect(response[1]).toMatchObject({ | ||
status: 200, | ||
body: 'success' | ||
}) | ||
|
||
// The third event fails as it doesn't have any products | ||
expect(response[2]).toMatchObject({ | ||
status: 400, | ||
errortype: 'PAYLOAD_VALIDATION_FAILED', | ||
errormessage: 'This event was not sent to Braze because it did not contain any products.', | ||
errorreporter: 'DESTINATION' | ||
}) | ||
|
||
// The third event fails as pre-request validation fails for not having a valid user identifier | ||
expect(response[2]).toMatchObject({ | ||
// The forth event fails as pre-request validation fails for not having a valid user identifier | ||
expect(response[3]).toMatchObject({ | ||
status: 400, | ||
errortype: 'PAYLOAD_VALIDATION_FAILED', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.', | ||
errorreporter: 'DESTINATION' | ||
}) | ||
}) | ||
|
@@ -542,6 +587,15 @@ describe('MultiStatus', () => { | |
externalId: 'test-external-id' | ||
} | ||
}), | ||
createTestEvent({ | ||
type: 'identify', | ||
receivedAt, | ||
traits: { | ||
firstName: 'Example', | ||
lastName: 'User', | ||
email: '[email protected]' | ||
} | ||
}), | ||
// Event without any user identifier | ||
createTestEvent({ | ||
type: 'identify', | ||
|
@@ -565,11 +619,17 @@ describe('MultiStatus', () => { | |
body: 'success' | ||
}) | ||
|
||
// The third event fails as pre-request validation fails for not having a valid user identifier | ||
// The second event doesn't fail as there is no error reported by Braze API | ||
expect(response[1]).toMatchObject({ | ||
status: 200, | ||
body: 'success' | ||
}) | ||
|
||
// The third event fails as pre-request validation fails for not having a valid user identifier | ||
expect(response[2]).toMatchObject({ | ||
status: 400, | ||
errortype: 'PAYLOAD_VALIDATION_FAILED', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.', | ||
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.', | ||
errorreporter: 'DESTINATION' | ||
}) | ||
}) | ||
|