-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add more tests for zoho utils
- Loading branch information
Showing
1 changed file
with
15 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,11 +206,25 @@ describe('searchRecordId', () => { | |
}, | ||
expected: { erroneous: true, message: 'No contact is found with record details' }, | ||
}, | ||
{ | ||
name: 'should handle network errors gracefully', | ||
input: { | ||
fields: { email: '[email protected]' }, | ||
metadata: { secret: { accessToken: 'token' } }, | ||
config: { region: 'US' }, | ||
mockError: new Error('Network timeout'), | ||
}, | ||
expected: { erroneous: true, message: 'Network timeout' }, | ||
}, | ||
]; | ||
|
||
testCases.forEach(({ name, input, expected }) => { | ||
it(name, async () => { | ||
handleHttpRequest.mockResolvedValue(input.mockResponse); | ||
if (input.mockError) { | ||
handleHttpRequest.mockRejectedValue(input.mockError); | ||
} else { | ||
handleHttpRequest.mockResolvedValue(input.mockResponse); | ||
} | ||
const result = await searchRecordId(input.fields, input.metadata, input.config); | ||
expect(result).toEqual(expected); | ||
}); | ||
|