Skip to content

Commit b4daa29

Browse files
committed
add test cases for onProgress and abort
1 parent 10ae4cd commit b4daa29

File tree

4 files changed

+284
-209
lines changed

4 files changed

+284
-209
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@rollup/plugin-node-resolve": "^8.4.0",
2323
"@rollup/plugin-typescript": "^8.2.1",
2424
"@types/node": "^15.6.1",
25+
"abortcontroller-polyfill": "^1.7.8",
2526
"babel-plugin-transform-class-properties": "^6.24.1",
2627
"chai": "^4.2.0",
2728
"codecov": "^3.8.0",
@@ -43,7 +44,7 @@
4344
"dev": "rollup -c -w",
4445
"export-types": "tsc",
4546
"build": "rm -rf dist*;rollup -c && yarn export-types",
46-
"test": "NODE_ENV=test nyc ./node_modules/mocha/bin/mocha \"test/**/*.js\"",
47+
"test": "NODE_ENV=test nyc ./node_modules/mocha/bin/mocha --require ./test/setup.js \"test/**/*.js\"",
4748
"startSampleApp": "yarn build && cd samples/sample-app/ && yarn install && node index.js",
4849
"report-coverage": "codecov"
4950
},

test/setup.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// test-setup.js (loaded before your tests)
2+
global.FormData = require("formdata-node");
3+
global.Blob = require("web-file-polyfill").Blob
4+
global.File = require("web-file-polyfill").File
5+
const { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill');
6+
global.AbortController = AbortController
7+
global.ProgressEvent = class FakeProgressEvent {
8+
constructor(type, init = {}) {
9+
this.type = type;
10+
this.lengthComputable = init.lengthComputable || false;
11+
this.loaded = init.loaded || 0;
12+
this.total = init.total || 0;
13+
}
14+
};

0 commit comments

Comments
 (0)