-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃帹 optimise error to inherit from in GhostError prototype (#7529)
refs #7116 - add errors_spec - inherit all given attribute values
- Loading branch information
Showing
2 changed files
with
75 additions
and
2 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,66 @@ | ||
var errors = require('../../server/errors'), | ||
should = require('should'); | ||
|
||
should.equal(true, true); | ||
|
||
describe('Errors', function () { | ||
describe('Inherite from other error', function () { | ||
it('default', function () { | ||
var someError = new Error(), ghostError; | ||
|
||
someError.message = 'test'; | ||
someError.context = 'test'; | ||
someError.help = 'test'; | ||
|
||
ghostError = new errors.GhostError({err: someError}); | ||
ghostError.message.should.eql(someError.message); | ||
ghostError.context.should.eql(someError.context); | ||
ghostError.help.should.eql(someError.help); | ||
}); | ||
|
||
it('has nested object', function () { | ||
var someError = new Error(), ghostError; | ||
|
||
someError.message = 'test'; | ||
someError.obj = { | ||
a: 'b' | ||
}; | ||
|
||
ghostError = new errors.GhostError({ | ||
err: someError | ||
}); | ||
|
||
ghostError.message.should.eql(someError.message); | ||
ghostError.obj.should.eql(someError.obj); | ||
}); | ||
|
||
it('with custom attribute', function () { | ||
var someError = new Error(), ghostError; | ||
|
||
someError.message = 'test'; | ||
someError.context = 'test'; | ||
|
||
ghostError = new errors.GhostError({ | ||
err: someError, | ||
context: 'context' | ||
}); | ||
|
||
ghostError.message.should.eql(someError.message); | ||
ghostError.context.should.eql('test'); | ||
}); | ||
|
||
it('with custom attribute', function () { | ||
var someError = new Error(), ghostError; | ||
|
||
someError.message = 'test'; | ||
|
||
ghostError = new errors.GhostError({ | ||
err: someError, | ||
context: 'context' | ||
}); | ||
|
||
ghostError.message.should.eql(someError.message); | ||
ghostError.context.should.eql('context'); | ||
}); | ||
}); | ||
}); |