Skip to content

Commit

Permalink
Add test case for error
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-joshi99 committed Mar 8, 2024
1 parent b897052 commit 473990d
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,24 @@ describe('Klaviyo (actions)', () => {
externalId: 'XYZABC'
})
})

it('should throw an IntegrationError when the response is not ok', async () => {
const errorMessage = 'List not found'
nock(`${API_URL}/lists`)
.get(`/${listId}`)
.reply(404, {
success: false,
errors: [
{
detail: errorMessage
}
]
})

const audiencePromise = testDestination.getAudience(getAudienceInput)
await expect(audiencePromise).rejects.toThrow(IntegrationError)
await expect(audiencePromise).rejects.toHaveProperty('message', errorMessage)
await expect(audiencePromise).rejects.toHaveProperty('code', 'INVALID_REQUEST_DATA')
})
})
})

0 comments on commit 473990d

Please sign in to comment.