-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef9be86
commit 9c2d34d
Showing
3 changed files
with
40 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { assert } = require('chai'); | ||
const MailosaurClient = require('../lib/mailosaur'); | ||
|
||
describe('error handling', () => { | ||
it('Unauthorized', (done) => { | ||
const client = new MailosaurClient('invalid_key'); | ||
client.servers.list().catch((err) => { | ||
assert.equal(err.toString(), 'Error: Authentication failed, check your API key.'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Not Found', (done) => { | ||
const client = new MailosaurClient(process.env.MAILOSAUR_API_KEY); | ||
client.servers.get('not_found').catch((err) => { | ||
assert.equal(err.toString(), 'Error: Not found, check input parameters.'); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Bad Request', (done) => { | ||
const client = new MailosaurClient(process.env.MAILOSAUR_API_KEY); | ||
client.servers.create({}).catch((err) => { | ||
assert.equal(err.toString(), 'Error: (name) Please provide a name for your server\r\n'); | ||
done(); | ||
}); | ||
}); | ||
}); |
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