forked from segmentio/action-destinations
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Loops-so/fix_tests
update tests and snapshots
- Loading branch information
Showing
3 changed files
with
22 additions
and
9 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 |
---|---|---|
|
@@ -44,7 +44,8 @@ describe('Loops.createOrUpdateContact', () => { | |
source: 'Segment', | ||
subscribed: true, | ||
userGroup: 'Alum', | ||
userId: 'some-id-1' | ||
userId: 'some-id-1', | ||
mailingLists: {} | ||
} | ||
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(200, { | ||
success: true, | ||
|
@@ -65,34 +66,44 @@ describe('Loops.createOrUpdateContact', () => { | |
}) | ||
|
||
it('should not work without email', async () => { | ||
const testPayload = { | ||
const testPayloadIn = { | ||
firstName: 'Ellen', | ||
userId: 'some-id-1' | ||
} | ||
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayload).reply(400, { | ||
const testPayloadOut = { | ||
firstName: 'Ellen', | ||
userId: 'some-id-1', | ||
mailingLists: {} | ||
} | ||
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(400, { | ||
success: false, | ||
message: 'userId not found and cannot create a new contact without an email.' | ||
}) | ||
await expect( | ||
testDestination.testAction('createOrUpdateContact', { | ||
mapping: testPayload, | ||
mapping: testPayloadIn, | ||
settings: { apiKey: LOOPS_API_KEY } | ||
}) | ||
).rejects.toThrow('Bad Request') | ||
}) | ||
|
||
it('should work without optional fields', async () => { | ||
const testPayload = { | ||
const testPayloadIn = { | ||
email: '[email protected]', | ||
userId: 'some-id-2' | ||
} | ||
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayload).reply(200, { | ||
const testPayloadOut = { | ||
email: '[email protected]', | ||
userId: 'some-id-2', | ||
mailingLists: {} | ||
} | ||
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(200, { | ||
success: true, | ||
id: 'someId' | ||
}) | ||
|
||
const responses = await testDestination.testAction('createOrUpdateContact', { | ||
mapping: testPayload, | ||
mapping: testPayloadIn, | ||
settings: { apiKey: LOOPS_API_KEY } | ||
}) | ||
|
||
|