Merge pull request #315 from bitinn/fix-test

Fix test cases for #314, #292
This commit is contained in:
David Frank 2017-07-22 21:26:50 +08:00 committed by GitHub
commit 721a9aa6b6
2 changed files with 10 additions and 10 deletions

View File

@ -56,5 +56,5 @@
"url-search-params": "^0.9.0",
"whatwg-url": "^4.0.0"
},
"dependencies": { }
"dependencies": {}
}

View File

@ -58,14 +58,14 @@ after(done => {
describe('node-fetch', () => {
it('should return a promise', function() {
url = 'http://example.com/';
url = `${base}hello`;
const p = fetch(url);
expect(p).to.be.an.instanceof(fetch.Promise);
expect(p).to.have.property('then');
});
it('should allow custom promise', function() {
url = 'http://example.com/';
url = `${base}hello`;
const old = fetch.Promise;
fetch.Promise = then;
expect(fetch(url)).to.be.an.instanceof(then);
@ -74,7 +74,7 @@ describe('node-fetch', () => {
});
it('should throw error when no promise implementation are found', function() {
url = 'http://example.com/';
url = `${base}hello`;
const old = fetch.Promise;
fetch.Promise = undefined;
expect(() => {
@ -626,24 +626,24 @@ describe('node-fetch', () => {
});
it('should clear internal timeout on fetch response', function (done) {
this.timeout(1000);
spawn('node', ['-e', `require('./')('${base}hello', { timeout: 5000 })`])
this.timeout(2000);
spawn('node', ['-e', `require('./')('${base}hello', { timeout: 10000 })`])
.on('exit', () => {
done();
});
});
it('should clear internal timeout on fetch redirect', function (done) {
this.timeout(1000);
spawn('node', ['-e', `require('./')('${base}redirect/301', { timeout: 5000 })`])
this.timeout(2000);
spawn('node', ['-e', `require('./')('${base}redirect/301', { timeout: 10000 })`])
.on('exit', () => {
done();
});
});
it('should clear internal timeout on fetch error', function (done) {
this.timeout(1000);
spawn('node', ['-e', `require('./')('${base}error/reset', { timeout: 5000 })`])
this.timeout(2000);
spawn('node', ['-e', `require('./')('${base}error/reset', { timeout: 10000 })`])
.on('exit', () => {
done();
});