diff --git a/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap b/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap index c5ee0d332d..8a7236bcc7 100644 --- a/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap +++ b/packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap @@ -7,7 +7,7 @@ Object { "firstName": "3dQ7ER]1HKW", "lastName": "3dQ7ER]1HKW", "mailingLists": Object { - "testType": "3dQ7ER]1HKW", + "3dQ7ER]1HKW": true, }, "source": "3dQ7ER]1HKW", "subscribed": true, @@ -19,6 +19,7 @@ Object { exports[`Testing snapshot for actions-loops destination: createOrUpdateContact action - required fields 1`] = ` Object { + "mailingLists": Object {}, "userId": "3dQ7ER]1HKW", } `; diff --git a/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/__snapshots__/snapshot.test.ts.snap b/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/__snapshots__/snapshot.test.ts.snap index 31a9c48d31..cf78988883 100644 --- a/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/__snapshots__/snapshot.test.ts.snap +++ b/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/__snapshots__/snapshot.test.ts.snap @@ -7,7 +7,7 @@ Object { "firstName": "IAIhDY9yOUxjQs(FSFfe", "lastName": "IAIhDY9yOUxjQs(FSFfe", "mailingLists": Object { - "testType": "IAIhDY9yOUxjQs(FSFfe", + "IAIhDY9yOUxjQs(FSFfe": false, }, "source": "IAIhDY9yOUxjQs(FSFfe", "subscribed": false, @@ -19,6 +19,7 @@ Object { exports[`Testing snapshot for Loops's createOrUpdateContact destination action: required fields 1`] = ` Object { + "mailingLists": Object {}, "userId": "IAIhDY9yOUxjQs(FSFfe", } `; diff --git a/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/index.test.ts b/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/index.test.ts index 0a69d9412b..caa0756f6b 100644 --- a/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/index.test.ts @@ -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: 'test@example.com', userId: 'some-id-2' } - nock('https://app.loops.so/api/v1').put('/contacts/update', testPayload).reply(200, { + const testPayloadOut = { + email: 'test@example.com', + 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 } })