-
Notifications
You must be signed in to change notification settings - Fork 19
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 #13 from blacksonic/master
feat(error): add constructor data attribute to property instead of extending itself
- Loading branch information
Showing
3 changed files
with
31 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ Usage | |
}).then(function(response) { | ||
console.log(response); | ||
}); | ||
|
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,25 @@ | ||
'use strict'; | ||
|
||
var SuiteRequestError = require('./requestError'); | ||
|
||
describe('SuiteRequestError', function() { | ||
it('should extend base Error class', function() { | ||
var error = new SuiteRequestError(); | ||
|
||
expect(error).to.be.an.instanceOf(Error); | ||
}); | ||
|
||
it('should store constructor parameters', function() { | ||
var error = new SuiteRequestError('Invalid request', 400, { detailedMessage: 'Line too long' }); | ||
|
||
expect(error.message).to.eql('Invalid request'); | ||
expect(error.code).to.eql(400); | ||
expect(error.data).to.eql({ detailedMessage: 'Line too long', replyText: 'Invalid request' }); | ||
}); | ||
|
||
it('should always contain replyText in data', function() { | ||
var error = new SuiteRequestError('Unauthorized'); | ||
|
||
expect(error.data.replyText).to.eql('Unauthorized'); | ||
}); | ||
}); |