@vnejs/helpers.call-all-promises 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/tests/call-all-promises.test.ts +21 -0
- package/tsconfig.json +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/helpers.call-all-promises",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tsconfig.json"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "npx @vnejs/monorepo test",
|
|
14
14
|
"build": "npx @vnejs/monorepo package",
|
|
15
15
|
"publish:major:plugin": "npm run publish:major",
|
|
16
16
|
"publish:minor:plugin": "npm run publish:minor",
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@vnejs/helpers.invoke-thunk": "~0.
|
|
25
|
+
"@vnejs/helpers.invoke-thunk": "~0.2.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@vnejs/configs.ts-common": "~0.
|
|
28
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
29
|
+
"@vnejs/configs.vitest": "~0.2.0"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { callAllPromises } from "../index.js";
|
|
4
|
+
|
|
5
|
+
describe("callAllPromises", () => {
|
|
6
|
+
it("calls thunks without argument", async () => {
|
|
7
|
+
await expect(callAllPromises([() => 1, () => 2])).resolves.toEqual([1, 2]);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("calls handlers with argument", async () => {
|
|
11
|
+
await expect(callAllPromises([(x: number) => x * 2, (x: number) => x + 1], 3)).resolves.toEqual([6, 4]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("awaits async handlers", async () => {
|
|
15
|
+
await expect(callAllPromises([async () => "a", async () => "b"])).resolves.toEqual(["a", "b"]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns empty array for no handlers", async () => {
|
|
19
|
+
await expect(callAllPromises([])).resolves.toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
});
|