Skip to content

Commit c6ca799

Browse files
committed
refactored tests to use vitest and added SendOptions support
1 parent 5440ce4 commit c6ca799

35 files changed

+1183
-734
lines changed

README.md

+11-12
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,19 @@ pb.collection('example').getList(2, 20) // cancelled
240240
pb.collection('example').getList(3, 20) // executed
241241
```
242242

243-
To change this behavior, you could make use of 2 special query parameters:
244-
245-
- `$autoCancel ` - set it to `false` to disable auto cancellation for this request
246-
- `$cancelKey` - set it to a string that will be used as request identifier and based on which pending requests will be matched (default to `HTTP_METHOD + path`, eg. "GET /api/users")
243+
To change this behavior per request basis, you can adjust the `requestKey: null|string` special query parameter.
244+
Set it to `null` to unset the default request identifier and to disable auto cancellation for the specific request.
245+
Or set it to a unique string that will be used as request identifier and based on which pending requests will be matched (default to `HTTP_METHOD + path`, eg. "GET /api/users")
247246

248247
Example:
249248

250249
```js
251-
pb.collection('example').getList(1, 20); // cancelled
252-
pb.collection('example').getList(1, 20); // executed
253-
pb.collection('example').getList(1, 20, { '$cancelKey': "test" }) // cancelled
254-
pb.collection('example').getList(1, 20, { '$cancelKey': "test" }) // executed
255-
pb.collection('example').getList(1, 20, { '$autoCancel': false }); // executed
256-
pb.collection('example').getList(1, 20, { '$autoCancel': false }) // executed
250+
pb.collection('example').getList(1, 20); // cancelled
251+
pb.collection('example').getList(1, 20); // executed
252+
pb.collection('example').getList(1, 20, { requestKey: "test" }) // cancelled
253+
pb.collection('example').getList(1, 20, { requestKey: "test" }) // executed
254+
pb.collection('example').getList(1, 20, { requestKey: null }) // executed
255+
pb.collection('example').getList(1, 20, { requestKey: null }) // executed
257256

258257
// globally disable auto cancellation
259258
pb.autoCancellation(false);
@@ -263,9 +262,9 @@ pb.collection('example').getList(1, 20); // executed
263262
pb.collection('example').getList(1, 20); // executed
264263
```
265264

266-
**If you want to completelly disable the auto cancellation behavior, you could set `pb.autoCancellation(false)`.**
265+
**If you want to globally disable the auto cancellation behavior, you could set `pb.autoCancellation(false)`.**
267266

268-
To manually cancel pending requests, you could use `pb.cancelAllRequests()` or `pb.cancelRequest(cancelKey)`.
267+
To manually cancel pending requests, you could use `pb.cancelAllRequests()` or `pb.cancelRequest(requestKey)`.
269268

270269

271270
### Custom Record types

package.json

+3-12
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,14 @@
2727
"scripts": {
2828
"build": "rm -rf dist && rollup -c",
2929
"dev": "rollup -c -w",
30-
"test": "env TS_NODE_PROJECT='tsconfig-test.json' mocha 'tests/**/*.spec.ts' -n loader=ts-node/esm",
30+
"test": "vitest",
3131
"prepublishOnly": "npm run build"
3232
},
3333
"devDependencies": {
3434
"@rollup/plugin-terser": "^0.4.3",
35-
"@types/chai": "^4.2.19",
36-
"@types/chai-as-promised": "^7.1.4",
37-
"@types/mocha": "^8.2.2",
38-
"@types/sinon": "^10.0.11",
39-
"chai": "^4.3.4",
40-
"chai-as-promised": "^7.1.1",
41-
"mocha": "^9.0.1",
4235
"rollup": "^3.0.0",
4336
"rollup-plugin-ts": "^3.0.0",
44-
"ts-node": "^10.0.0",
45-
"tsconfig-paths": "^4.0.0",
46-
"tslib": "^2.4.0",
47-
"typescript": "^5.1.6"
37+
"typescript": "^5.1.6",
38+
"vitest": "^0.34.1"
4839
}
4940
}

0 commit comments

Comments
 (0)