Skip to content

Commit a9b8c4f

Browse files
authored
Merge pull request #5 from Loops-so/fix_tests
update tests and snapshots
2 parents 954b21d + 9d27c0c commit a9b8c4f

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

packages/destination-actions/src/destinations/loops/__tests__/__snapshots__/snapshot.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Object {
77
"firstName": "3dQ7ER]1HKW",
88
"lastName": "3dQ7ER]1HKW",
99
"mailingLists": Object {
10-
"testType": "3dQ7ER]1HKW",
10+
"3dQ7ER]1HKW": true,
1111
},
1212
"source": "3dQ7ER]1HKW",
1313
"subscribed": true,
@@ -19,6 +19,7 @@ Object {
1919

2020
exports[`Testing snapshot for actions-loops destination: createOrUpdateContact action - required fields 1`] = `
2121
Object {
22+
"mailingLists": Object {},
2223
"userId": "3dQ7ER]1HKW",
2324
}
2425
`;

packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/__snapshots__/snapshot.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Object {
77
"firstName": "IAIhDY9yOUxjQs(FSFfe",
88
"lastName": "IAIhDY9yOUxjQs(FSFfe",
99
"mailingLists": Object {
10-
"testType": "IAIhDY9yOUxjQs(FSFfe",
10+
"IAIhDY9yOUxjQs(FSFfe": false,
1111
},
1212
"source": "IAIhDY9yOUxjQs(FSFfe",
1313
"subscribed": false,
@@ -19,6 +19,7 @@ Object {
1919

2020
exports[`Testing snapshot for Loops's createOrUpdateContact destination action: required fields 1`] = `
2121
Object {
22+
"mailingLists": Object {},
2223
"userId": "IAIhDY9yOUxjQs(FSFfe",
2324
}
2425
`;

packages/destination-actions/src/destinations/loops/createOrUpdateContact/__tests__/index.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ describe('Loops.createOrUpdateContact', () => {
4444
source: 'Segment',
4545
subscribed: true,
4646
userGroup: 'Alum',
47-
userId: 'some-id-1'
47+
userId: 'some-id-1',
48+
mailingLists: {}
4849
}
4950
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(200, {
5051
success: true,
@@ -65,34 +66,44 @@ describe('Loops.createOrUpdateContact', () => {
6566
})
6667

6768
it('should not work without email', async () => {
68-
const testPayload = {
69+
const testPayloadIn = {
6970
firstName: 'Ellen',
7071
userId: 'some-id-1'
7172
}
72-
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayload).reply(400, {
73+
const testPayloadOut = {
74+
firstName: 'Ellen',
75+
userId: 'some-id-1',
76+
mailingLists: {}
77+
}
78+
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(400, {
7379
success: false,
7480
message: 'userId not found and cannot create a new contact without an email.'
7581
})
7682
await expect(
7783
testDestination.testAction('createOrUpdateContact', {
78-
mapping: testPayload,
84+
mapping: testPayloadIn,
7985
settings: { apiKey: LOOPS_API_KEY }
8086
})
8187
).rejects.toThrow('Bad Request')
8288
})
8389

8490
it('should work without optional fields', async () => {
85-
const testPayload = {
91+
const testPayloadIn = {
8692
8793
userId: 'some-id-2'
8894
}
89-
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayload).reply(200, {
95+
const testPayloadOut = {
96+
97+
userId: 'some-id-2',
98+
mailingLists: {}
99+
}
100+
nock('https://app.loops.so/api/v1').put('/contacts/update', testPayloadOut).reply(200, {
90101
success: true,
91102
id: 'someId'
92103
})
93104

94105
const responses = await testDestination.testAction('createOrUpdateContact', {
95-
mapping: testPayload,
106+
mapping: testPayloadIn,
96107
settings: { apiKey: LOOPS_API_KEY }
97108
})
98109

0 commit comments

Comments
 (0)