Merge branch 'master' of https://github.com/node-fetch/node-fetch
This commit is contained in:
commit
a3cee3f6e7
|
@ -52,8 +52,10 @@
|
|||
"chai-iterator": "^3.0.2",
|
||||
"chai-string": "^1.5.0",
|
||||
"coveralls": "^3.1.0",
|
||||
"delay": "^4.3.0",
|
||||
"form-data": "^3.0.0",
|
||||
"mocha": "^7.2.0",
|
||||
"p-timeout": "^3.2.0",
|
||||
"parted": "^0.1.1",
|
||||
"promise": "^8.1.0",
|
||||
"resumer": "0.0.0",
|
||||
|
@ -82,8 +84,8 @@
|
|||
"@typescript-eslint/prefer-readonly-parameter-types": 0,
|
||||
"import/extensions": 0,
|
||||
"import/no-useless-path-segments": 0,
|
||||
"unicorn/import-index": 0,
|
||||
"capitalized-comments": 0
|
||||
"unicorn/import-index": 0,
|
||||
"capitalized-comments": 0
|
||||
},
|
||||
"ignores": [
|
||||
"dist",
|
||||
|
|
|
@ -15,11 +15,11 @@ import then from 'promise';
|
|||
import resumer from 'resumer';
|
||||
import FormData from 'form-data';
|
||||
import stringToArrayBuffer from 'string-to-arraybuffer';
|
||||
|
||||
import polyfill from 'abortcontroller-polyfill/dist/abortcontroller.js';
|
||||
import delay from 'delay';
|
||||
import AbortControllerPolyfill from 'abortcontroller-polyfill/dist/abortcontroller.js';
|
||||
import AbortController2 from 'abort-controller';
|
||||
|
||||
const {AbortController} = polyfill;
|
||||
const {AbortController} = AbortControllerPolyfill;
|
||||
|
||||
// Test subjects
|
||||
import Blob from 'fetch-blob';
|
||||
|
@ -35,7 +35,6 @@ import HeadersOrig, {createHeadersLenient} from '../src/headers.js';
|
|||
import RequestOrig from '../src/request.js';
|
||||
import ResponseOrig from '../src/response.js';
|
||||
import Body, {getTotalBytes, extractContentType} from '../src/body.js';
|
||||
import delay from './utils/delay.js';
|
||||
import TestServer from './utils/server.js';
|
||||
|
||||
const {
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
import pTimeout from 'p-timeout';
|
||||
|
||||
export default ({Assertion}, utils) => {
|
||||
utils.addProperty(Assertion.prototype, 'timeout', function () {
|
||||
return new Promise(resolve => {
|
||||
const timer = setTimeout(() => resolve(true), 150);
|
||||
this._obj.then(() => {
|
||||
clearTimeout(timer);
|
||||
resolve(false);
|
||||
});
|
||||
}).then(timeouted => {
|
||||
this.assert(
|
||||
timeouted,
|
||||
'expected promise to timeout but it was resolved',
|
||||
'expected promise not to timeout but it timed out'
|
||||
);
|
||||
utils.addProperty(Assertion.prototype, 'timeout', async function () {
|
||||
let timeouted = false;
|
||||
await pTimeout(this._obj, 150, () => {
|
||||
timeouted = true;
|
||||
});
|
||||
return this.assert(
|
||||
timeouted,
|
||||
'expected promise to timeout but it was resolved',
|
||||
'expected promise not to timeout but it timed out'
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
export default function delay(ms) {
|
||||
return value => new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(value);
|
||||
}, ms);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue