@teamkeel/testing-runtime 0.365.16-prerelease2 → 0.365.16-prerelease5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/testing-runtime",
3
- "version": "0.365.16-prerelease2",
3
+ "version": "0.365.16-prerelease5",
4
4
  "description": "Internal package used by the generated @teamkeel/testing package",
5
5
  "exports": "./src/index.mjs",
6
6
  "typings": "src/index.d.ts",
package/src/Executor.mjs CHANGED
@@ -103,8 +103,6 @@ export class Executor {
103
103
 
104
104
  if (this._parseJsonResult) {
105
105
  return r.json();
106
- } else {
107
- return true;
108
106
  }
109
107
  });
110
108
  }
package/src/index.d.ts CHANGED
@@ -8,6 +8,7 @@ interface ActionError {
8
8
 
9
9
  interface CustomMatchers<R = unknown> {
10
10
  toHaveAuthorizationError(): void;
11
+ toHaveAuthenticationError(): void;
11
12
  toHaveError(err: Partial<ActionError>): void;
12
13
  }
13
14
 
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,
@@ -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
  });