@teamkeel/testing-runtime 0.365.16-prerelease1 → 0.365.16-prerelease10
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 +1 -1
- package/src/Executor.mjs +0 -2
- package/src/index.d.ts +1 -0
- package/src/index.mjs +1 -0
- package/src/index.test.ts +35 -0
- package/src/toHaveAuthenticationError.mjs +23 -0
- package/src/toHaveAuthorizationError.mjs +2 -5
- package/src/vitest-setup.mjs +2 -0
package/package.json
CHANGED
package/src/Executor.mjs
CHANGED
package/src/index.d.ts
CHANGED
package/src/index.mjs
CHANGED
|
@@ -4,3 +4,4 @@ export { JobExecutor } from "./JobExecutor.mjs";
|
|
|
4
4
|
export { SubscriberExecutor } from "./SubscriberExecutor.mjs";
|
|
5
5
|
export { toHaveError } from "./toHaveError.mjs";
|
|
6
6
|
export { toHaveAuthorizationError } from "./toHaveAuthorizationError.mjs";
|
|
7
|
+
export { toHaveAuthenticationError } from "./toHaveAuthenticationError.mjs";
|
package/src/index.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ test("toHaveAuthorizationError", async () => {
|
|
|
5
5
|
const p = Promise.reject({
|
|
6
6
|
code: "ERR_PERMISSION_DENIED",
|
|
7
7
|
});
|
|
8
|
+
|
|
8
9
|
await expect(p).toHaveAuthorizationError();
|
|
9
10
|
});
|
|
10
11
|
|
|
@@ -12,9 +13,43 @@ test("not.toHaveAuthorizationError", async () => {
|
|
|
12
13
|
const p = Promise.resolve({
|
|
13
14
|
id: "foo",
|
|
14
15
|
});
|
|
16
|
+
|
|
17
|
+
await expect(p).not.toHaveAuthorizationError();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("not.toHaveAuthorizationError", async () => {
|
|
21
|
+
const p = Promise.reject({
|
|
22
|
+
code: "ERR_INVALID_INPUT",
|
|
23
|
+
message: "Invalid input",
|
|
24
|
+
});
|
|
25
|
+
|
|
15
26
|
await expect(p).not.toHaveAuthorizationError();
|
|
16
27
|
});
|
|
17
28
|
|
|
29
|
+
test("toHaveAuthenticationError", async () => {
|
|
30
|
+
const p = Promise.reject({
|
|
31
|
+
code: "ERR_AUTHENTICATION_FAILED",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await expect(p).toHaveAuthenticationError();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("not.toHaveAuthenticationError", async () => {
|
|
38
|
+
const p = Promise.resolve({
|
|
39
|
+
id: "foo",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await expect(p).not.toHaveAuthenticationError();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("not.toHaveAuthenticationError", async () => {
|
|
46
|
+
const p = Promise.reject({
|
|
47
|
+
code: "ERR_PERMISSION_DENIED",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await expect(p).not.toHaveAuthenticationError();
|
|
51
|
+
});
|
|
52
|
+
|
|
18
53
|
test("toHaveError", async () => {
|
|
19
54
|
const p = Promise.reject({
|
|
20
55
|
code: "ERR_INVALID_INPUT",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export async function toHaveAuthenticationError(received) {
|
|
2
|
+
const { isNot } = this;
|
|
3
|
+
try {
|
|
4
|
+
const v = await received;
|
|
5
|
+
return {
|
|
6
|
+
pass: false,
|
|
7
|
+
message: () => "expected value to reject",
|
|
8
|
+
actual: v,
|
|
9
|
+
};
|
|
10
|
+
} catch (err) {
|
|
11
|
+
return {
|
|
12
|
+
pass: err.code === "ERR_AUTHENTICATION_FAILED",
|
|
13
|
+
message: () =>
|
|
14
|
+
`expected there to be ${
|
|
15
|
+
isNot ? "no " : ""
|
|
16
|
+
}ERR_AUTHENTICATION_FAILED error`,
|
|
17
|
+
actual: err,
|
|
18
|
+
expected: {
|
|
19
|
+
...err,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -9,12 +9,9 @@ export async function toHaveAuthorizationError(received) {
|
|
|
9
9
|
};
|
|
10
10
|
} catch (err) {
|
|
11
11
|
return {
|
|
12
|
-
pass:
|
|
13
|
-
err.code === "ERR_PERMISSION_DENIED" || err.code === "ERR_UNAUTHORIZED",
|
|
12
|
+
pass: err.code === "ERR_PERMISSION_DENIED",
|
|
14
13
|
message: () =>
|
|
15
|
-
`expected there to be ${
|
|
16
|
-
isNot ? "no " : ""
|
|
17
|
-
}ERR_PERMISSION_DENIED or ERR_UNAUTHORIZED error`,
|
|
14
|
+
`expected there to be ${isNot ? "no " : ""}ERR_PERMISSION_DENIED error`,
|
|
18
15
|
actual: err,
|
|
19
16
|
expected: {
|
|
20
17
|
...err,
|
package/src/vitest-setup.mjs
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
import { expect } from "vitest";
|
|
6
6
|
import { toHaveError } from "./toHaveError";
|
|
7
7
|
import { toHaveAuthorizationError } from "./toHaveAuthorizationError";
|
|
8
|
+
import { toHaveAuthenticationError } from "./toHaveAuthenticationError";
|
|
8
9
|
|
|
9
10
|
expect.extend({
|
|
10
11
|
toHaveError,
|
|
11
12
|
toHaveAuthorizationError,
|
|
13
|
+
toHaveAuthenticationError,
|
|
12
14
|
});
|