-
Notifications
You must be signed in to change notification settings - Fork 66
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 #350 from mollie/pimm/better-credential-feedback
More helpful error in createMollieClient for missing credentials.
- Loading branch information
Showing
3 changed files
with
41 additions
and
6 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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import createMollieClient from '../..'; | ||
|
||
describe('mollie', () => { | ||
it('should fail when no api key is provided', () => { | ||
describe('createMollieClient', () => { | ||
it('should fail when no credentials are provided', () => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore | ||
expect(() => createMollieClient(undefined)).toThrowError(TypeError); | ||
expect(() => createMollieClient({})).toThrow('Missing parameter "apiKey" or "accessToken".'); | ||
}); | ||
|
||
it('should throw a descriptive error when a apiKey is set to null', () => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore | ||
expect(() => createMollieClient({ apiKey: null })).toThrow('Parameter "apiKey" is null.'); | ||
}); | ||
|
||
it('should throw a descriptive error when a apiKey is set to an empty string', () => { | ||
expect(() => createMollieClient({ apiKey: '' })).toThrow('Parameter "apiKey" is an empty string.'); | ||
}); | ||
}); |