check that FetchError is an instanceof Error

This commit is contained in:
David Frank 2016-04-06 01:54:20 +08:00
parent ea8d7ca15f
commit d28febd497
1 changed files with 14 additions and 0 deletions

View File

@ -1175,6 +1175,20 @@ describe('node-fetch', function() {
expect(body).to.have.property('json');
});
it('should create custom FetchError', function() {
var systemError = new Error('system');
systemError.code = 'ESOMEERROR';
var err = new FetchError('test message', 'test-error', systemError);
expect(err).to.be.an.instanceof(Error);
expect(err).to.be.an.instanceof(FetchError);
expect(err.name).to.equal('FetchError');
expect(err.message).to.equal('test message');
expect(err.type).to.equal('test-error');
expect(err.code).to.equal('ESOMEERROR');
expect(err.errno).to.equal('ESOMEERROR');
});
it('should support https request', function() {
this.timeout(5000);
url = 'https://github.com/';