Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding failing tests that verify errors contain the request
- Loading branch information
1 parent
5c8095e
commit e0d59eb
Showing
4 changed files
with
23 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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
var createError = require('../../../lib/core/createError'); | ||
|
||
describe('core::createError', function() { | ||
it('should create an Error with message, config, and code', function() { | ||
var error = createError('Boom!', { foo: 'bar' }, 'ESOMETHING'); | ||
it('should create an Error with message, config, code, request and response', function() { | ||
var request = { path: '/foo' }; | ||
var response = { status: 200, data: { foo: 'bar' } }; | ||
var error = createError('Boom!', { foo: 'bar' }, 'ESOMETHING', request, response); | ||
expect(error instanceof Error).toBe(true); | ||
expect(error.message).toBe('Boom!'); | ||
expect(error.config).toEqual({ foo: 'bar' }); | ||
expect(error.code).toBe('ESOMETHING'); | ||
expect(error.request).toBe(request); | ||
expect(error.response).toBe(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
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