@effectionx/bdd 0.1.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.
Files changed (40) hide show
  1. package/README.md +171 -0
  2. package/esm/_dnt.shims.d.ts +2 -0
  3. package/esm/_dnt.shims.d.ts.map +1 -0
  4. package/esm/_dnt.shims.js +57 -0
  5. package/esm/deps/jsr.io/@std/assert/1.0.14/assertion_error.d.ts +26 -0
  6. package/esm/deps/jsr.io/@std/assert/1.0.14/assertion_error.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@std/assert/1.0.14/assertion_error.js +30 -0
  8. package/esm/deps/jsr.io/@std/internal/1.0.10/assertion_state.d.ts +150 -0
  9. package/esm/deps/jsr.io/@std/internal/1.0.10/assertion_state.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@std/internal/1.0.10/assertion_state.js +237 -0
  11. package/esm/deps/jsr.io/@std/testing/1.0.15/_test_suite.d.ts +78 -0
  12. package/esm/deps/jsr.io/@std/testing/1.0.15/_test_suite.d.ts.map +1 -0
  13. package/esm/deps/jsr.io/@std/testing/1.0.15/_test_suite.js +385 -0
  14. package/esm/deps/jsr.io/@std/testing/1.0.15/bdd.d.ts +336 -0
  15. package/esm/deps/jsr.io/@std/testing/1.0.15/bdd.d.ts.map +1 -0
  16. package/esm/deps/jsr.io/@std/testing/1.0.15/bdd.js +1057 -0
  17. package/esm/mod.d.ts +13 -0
  18. package/esm/mod.d.ts.map +1 -0
  19. package/esm/mod.js +47 -0
  20. package/esm/package.json +3 -0
  21. package/package.json +31 -0
  22. package/script/_dnt.shims.d.ts +2 -0
  23. package/script/_dnt.shims.d.ts.map +1 -0
  24. package/script/_dnt.shims.js +60 -0
  25. package/script/deps/jsr.io/@std/assert/1.0.14/assertion_error.d.ts +26 -0
  26. package/script/deps/jsr.io/@std/assert/1.0.14/assertion_error.d.ts.map +1 -0
  27. package/script/deps/jsr.io/@std/assert/1.0.14/assertion_error.js +34 -0
  28. package/script/deps/jsr.io/@std/internal/1.0.10/assertion_state.d.ts +150 -0
  29. package/script/deps/jsr.io/@std/internal/1.0.10/assertion_state.d.ts.map +1 -0
  30. package/script/deps/jsr.io/@std/internal/1.0.10/assertion_state.js +275 -0
  31. package/script/deps/jsr.io/@std/testing/1.0.15/_test_suite.d.ts +78 -0
  32. package/script/deps/jsr.io/@std/testing/1.0.15/_test_suite.d.ts.map +1 -0
  33. package/script/deps/jsr.io/@std/testing/1.0.15/_test_suite.js +389 -0
  34. package/script/deps/jsr.io/@std/testing/1.0.15/bdd.d.ts +336 -0
  35. package/script/deps/jsr.io/@std/testing/1.0.15/bdd.d.ts.map +1 -0
  36. package/script/deps/jsr.io/@std/testing/1.0.15/bdd.js +1068 -0
  37. package/script/mod.d.ts +13 -0
  38. package/script/mod.d.ts.map +1 -0
  39. package/script/mod.js +52 -0
  40. package/script/package.json +3 -0
package/esm/mod.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { Operation } from "effection";
2
+ export declare function describe(name: string, body: () => void): void;
3
+ export declare namespace describe {
4
+ var skip: <T>(...args: import("./deps/jsr.io/@std/testing/1.0.15/bdd.js").DescribeArgs<T>) => import("./deps/jsr.io/@std/testing/1.0.15/_test_suite.js").TestSuite<T>;
5
+ var only: <T>(...args: import("./deps/jsr.io/@std/testing/1.0.15/bdd.js").DescribeArgs<T>) => import("./deps/jsr.io/@std/testing/1.0.15/_test_suite.js").TestSuite<T>;
6
+ }
7
+ export declare function beforeEach(body: () => Operation<void>): void;
8
+ export declare function it(desc: string, body?: () => Operation<void>): void;
9
+ export declare namespace it {
10
+ var skip: (desc: string, body?: (() => Operation<void>) | undefined) => ReturnType<typeof it>;
11
+ var only: (desc: string, body: () => Operation<void>) => void;
12
+ }
13
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAS3C,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,QAYtD;yBAZe,QAAQ;;;;AAiBxB,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,QAErD;AAED,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAYnE;yBAZe,EAAE;2CAA4B,SAAS,CAAC,IAAI,CAAC,kBAcjB,UAAU,CAAC,OAAO,EAAE,CAAC;qBAKhD,MAAM,QAAQ,MAAM,SAAS,CAAC,IAAI,CAAC,KAAG,IAAI"}
package/esm/mod.js ADDED
@@ -0,0 +1,47 @@
1
+ import { createTestAdapter } from "@effectionx/test-adapter";
2
+ import { afterAll as $afterAll, describe as $describe, it as $it, } from "./deps/jsr.io/@std/testing/1.0.15/bdd.js";
3
+ let current;
4
+ export function describe(name, body) {
5
+ const original = current;
6
+ try {
7
+ const child = current = createTestAdapter({ name, parent: original });
8
+ $describe(name, () => {
9
+ $afterAll(() => child.destroy());
10
+ body();
11
+ });
12
+ }
13
+ finally {
14
+ current = original;
15
+ }
16
+ }
17
+ describe.skip = $describe.skip;
18
+ describe.only = $describe.only;
19
+ export function beforeEach(body) {
20
+ current?.addSetup(body);
21
+ }
22
+ export function it(desc, body) {
23
+ const adapter = current;
24
+ if (!body) {
25
+ $it.skip(desc, () => { });
26
+ return;
27
+ }
28
+ $it(desc, async () => {
29
+ const result = await adapter.runTest(body);
30
+ if (!result.ok) {
31
+ throw result.error;
32
+ }
33
+ });
34
+ }
35
+ it.skip = (...args) => {
36
+ const [desc] = args;
37
+ return $it.skip(desc, () => { });
38
+ };
39
+ it.only = (desc, body) => {
40
+ const adapter = current;
41
+ $it.only(desc, async () => {
42
+ const result = await adapter.runTest(body);
43
+ if (!result.ok) {
44
+ throw result.error;
45
+ }
46
+ });
47
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@effectionx/bdd",
3
+ "version": "0.1.0",
4
+ "author": "engineering@frontside.com",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/thefrontside/effectionx.git"
8
+ },
9
+ "license": "MIT",
10
+ "bugs": {
11
+ "url": "https://github.com/thefrontside/effectionx/issues"
12
+ },
13
+ "main": "./script/mod.js",
14
+ "module": "./esm/mod.js",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./esm/mod.js",
18
+ "require": "./script/mod.js"
19
+ }
20
+ },
21
+ "scripts": {},
22
+ "engines": {
23
+ "node": ">= 16"
24
+ },
25
+ "sideEffects": false,
26
+ "dependencies": {
27
+ "@effectionx/test-adapter": "0.4.0",
28
+ "effection": "^3"
29
+ },
30
+ "_generatedBy": "dnt@dev"
31
+ }
@@ -0,0 +1,2 @@
1
+ export declare const dntGlobalThis: Omit<typeof globalThis, never>;
2
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dntGlobalThis = void 0;
4
+ const dntGlobals = {};
5
+ exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
6
+ function createMergeProxy(baseObj, extObj) {
7
+ return new Proxy(baseObj, {
8
+ get(_target, prop, _receiver) {
9
+ if (prop in extObj) {
10
+ return extObj[prop];
11
+ }
12
+ else {
13
+ return baseObj[prop];
14
+ }
15
+ },
16
+ set(_target, prop, value) {
17
+ if (prop in extObj) {
18
+ delete extObj[prop];
19
+ }
20
+ baseObj[prop] = value;
21
+ return true;
22
+ },
23
+ deleteProperty(_target, prop) {
24
+ let success = false;
25
+ if (prop in extObj) {
26
+ delete extObj[prop];
27
+ success = true;
28
+ }
29
+ if (prop in baseObj) {
30
+ delete baseObj[prop];
31
+ success = true;
32
+ }
33
+ return success;
34
+ },
35
+ ownKeys(_target) {
36
+ const baseKeys = Reflect.ownKeys(baseObj);
37
+ const extKeys = Reflect.ownKeys(extObj);
38
+ const extKeysSet = new Set(extKeys);
39
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
40
+ },
41
+ defineProperty(_target, prop, desc) {
42
+ if (prop in extObj) {
43
+ delete extObj[prop];
44
+ }
45
+ Reflect.defineProperty(baseObj, prop, desc);
46
+ return true;
47
+ },
48
+ getOwnPropertyDescriptor(_target, prop) {
49
+ if (prop in extObj) {
50
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
51
+ }
52
+ else {
53
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
54
+ }
55
+ },
56
+ has(_target, prop) {
57
+ return prop in extObj || prop in baseObj;
58
+ },
59
+ });
60
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Error thrown when an assertion fails.
3
+ *
4
+ * @example Usage
5
+ * ```ts ignore
6
+ * import { AssertionError } from "@std/assert";
7
+ *
8
+ * try {
9
+ * throw new AssertionError("foo", { cause: "bar" });
10
+ * } catch (error) {
11
+ * if (error instanceof AssertionError) {
12
+ * error.message === "foo"; // true
13
+ * error.cause === "bar"; // true
14
+ * }
15
+ * }
16
+ * ```
17
+ */
18
+ export declare class AssertionError extends Error {
19
+ /** Constructs a new instance.
20
+ *
21
+ * @param message The error message.
22
+ * @param options Additional options. This argument is still unstable. It may change in the future release.
23
+ */
24
+ constructor(message: string, options?: ErrorOptions);
25
+ }
26
+ //# sourceMappingURL=assertion_error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.14/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ // Copyright 2018-2025 the Deno authors. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.AssertionError = void 0;
6
+ /**
7
+ * Error thrown when an assertion fails.
8
+ *
9
+ * @example Usage
10
+ * ```ts ignore
11
+ * import { AssertionError } from "@std/assert";
12
+ *
13
+ * try {
14
+ * throw new AssertionError("foo", { cause: "bar" });
15
+ * } catch (error) {
16
+ * if (error instanceof AssertionError) {
17
+ * error.message === "foo"; // true
18
+ * error.cause === "bar"; // true
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ class AssertionError extends Error {
24
+ /** Constructs a new instance.
25
+ *
26
+ * @param message The error message.
27
+ * @param options Additional options. This argument is still unstable. It may change in the future release.
28
+ */
29
+ constructor(message, options) {
30
+ super(message, options);
31
+ this.name = "AssertionError";
32
+ }
33
+ }
34
+ exports.AssertionError = AssertionError;
@@ -0,0 +1,150 @@
1
+ export declare class AssertionState {
2
+ #private;
3
+ constructor();
4
+ /**
5
+ * Get the number that through `expect.assertions` api set.
6
+ *
7
+ * @returns the number that through `expect.assertions` api set.
8
+ *
9
+ * @example Usage
10
+ * ```ts ignore
11
+ * import { AssertionState } from "@std/internal";
12
+ *
13
+ * const assertionState = new AssertionState();
14
+ * assertionState.assertionCount;
15
+ * ```
16
+ */
17
+ get assertionCount(): number | undefined;
18
+ /**
19
+ * Get a certain number that assertions were called before.
20
+ *
21
+ * @returns return a certain number that assertions were called before.
22
+ *
23
+ * @example Usage
24
+ * ```ts ignore
25
+ * import { AssertionState } from "@std/internal";
26
+ *
27
+ * const assertionState = new AssertionState();
28
+ * assertionState.assertionTriggeredCount;
29
+ * ```
30
+ */
31
+ get assertionTriggeredCount(): number;
32
+ /**
33
+ * If `expect.hasAssertions` called, then through this method to update #state.assertionCheck value.
34
+ *
35
+ * @param val Set #state.assertionCheck's value
36
+ *
37
+ * @example Usage
38
+ * ```ts ignore
39
+ * import { AssertionState } from "@std/internal";
40
+ *
41
+ * const assertionState = new AssertionState();
42
+ * assertionState.setAssertionCheck(true);
43
+ * ```
44
+ */
45
+ setAssertionCheck(val: boolean): void;
46
+ /**
47
+ * If any matchers was called, `#state.assertionTriggered` will be set through this method.
48
+ *
49
+ * @param val Set #state.assertionTriggered's value
50
+ *
51
+ * @example Usage
52
+ * ```ts ignore
53
+ * import { AssertionState } from "@std/internal";
54
+ *
55
+ * const assertionState = new AssertionState();
56
+ * assertionState.setAssertionTriggered(true);
57
+ * ```
58
+ */
59
+ setAssertionTriggered(val: boolean): void;
60
+ /**
61
+ * If `expect.assertions` called, then through this method to update #state.assertionCheck value.
62
+ *
63
+ * @param num Set #state.assertionCount's value, for example if the value is set 2, that means
64
+ * you must have two assertion matchers call in your test suite.
65
+ *
66
+ * @example Usage
67
+ * ```ts ignore
68
+ * import { AssertionState } from "@std/internal";
69
+ *
70
+ * const assertionState = new AssertionState();
71
+ * assertionState.setAssertionCount(2);
72
+ * ```
73
+ */
74
+ setAssertionCount(num: number): void;
75
+ /**
76
+ * If any matchers was called, `#state.assertionTriggeredCount` value will plus one internally.
77
+ *
78
+ * @example Usage
79
+ * ```ts ignore
80
+ * import { AssertionState } from "@std/internal";
81
+ *
82
+ * const assertionState = new AssertionState();
83
+ * assertionState.updateAssertionTriggerCount();
84
+ * ```
85
+ */
86
+ updateAssertionTriggerCount(): void;
87
+ /**
88
+ * Check Assertion internal state, if `#state.assertionCheck` is set true, but
89
+ * `#state.assertionTriggered` is still false, then should throw an Assertion Error.
90
+ *
91
+ * @returns a boolean value, that the test suite is satisfied with the check. If not,
92
+ * it should throw an AssertionError.
93
+ *
94
+ * @example Usage
95
+ * ```ts ignore
96
+ * import { AssertionState } from "@std/internal";
97
+ *
98
+ * const assertionState = new AssertionState();
99
+ * if (assertionState.checkAssertionErrorState()) {
100
+ * // throw AssertionError("");
101
+ * }
102
+ * ```
103
+ */
104
+ checkAssertionErrorState(): boolean;
105
+ /**
106
+ * Reset all assertion state when every test suite function ran completely.
107
+ *
108
+ * @example Usage
109
+ * ```ts ignore
110
+ * import { AssertionState } from "@std/internal";
111
+ *
112
+ * const assertionState = new AssertionState();
113
+ * assertionState.resetAssertionState();
114
+ * ```
115
+ */
116
+ resetAssertionState(): void;
117
+ /**
118
+ * Check Assertion called state, if `#state.assertionCount` is set to a number value, but
119
+ * `#state.assertionTriggeredCount` is less then it, then should throw an assertion error.
120
+ *
121
+ * @returns a boolean value, that the test suite is satisfied with the check. If not,
122
+ * it should throw an AssertionError.
123
+ *
124
+ * @example Usage
125
+ * ```ts ignore
126
+ * import { AssertionState } from "@std/internal";
127
+ *
128
+ * const assertionState = new AssertionState();
129
+ * if (assertionState.checkAssertionCountSatisfied()) {
130
+ * // throw AssertionError("");
131
+ * }
132
+ * ```
133
+ */
134
+ checkAssertionCountSatisfied(): boolean;
135
+ }
136
+ /**
137
+ * return an instance of AssertionState
138
+ *
139
+ * @returns AssertionState
140
+ *
141
+ * @example Usage
142
+ * ```ts ignore
143
+ * import { getAssertionState } from "@std/internal";
144
+ *
145
+ * const assertionState = getAssertionState();
146
+ * assertionState.setAssertionTriggered(true);
147
+ * ```
148
+ */
149
+ export declare function getAssertionState(): AssertionState;
150
+ //# sourceMappingURL=assertion_state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion_state.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.10/assertion_state.ts"],"names":[],"mappings":"AAeA,qBAAa,cAAc;;;IAgDzB;;;;;;;;;;;;OAYG;IACH,IAAI,cAAc,IAAI,MAAM,GAAG,SAAS,CAEvC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,uBAAuB,IAAI,MAAM,CAEpC;IAED;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,GAAG,EAAE,OAAO;IAI9B;;;;;;;;;;;;OAYG;IACH,qBAAqB,CAAC,GAAG,EAAE,OAAO;IAIlC;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM;IAI7B;;;;;;;;;;OAUG;IACH,2BAA2B;IAM3B;;;;;;;;;;;;;;;;OAgBG;IACH,wBAAwB,IAAI,OAAO;IAInC;;;;;;;;;;OAUG;IACH,mBAAmB,IAAI,IAAI;IAS3B;;;;;;;;;;;;;;;;OAgBG;IACH,4BAA4B,IAAI,OAAO;CAIxC;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAElD"}
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ // Copyright 2018-2025 the Deno authors. MIT license.
3
+ // This module is browser compatible.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
38
+ if (kind === "m") throw new TypeError("Private method is not writable");
39
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
40
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
41
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
42
+ };
43
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
44
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
45
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
46
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
47
+ };
48
+ var _AssertionState_instances, _AssertionState_state, _AssertionState_ensureCleanedUp;
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.AssertionState = void 0;
51
+ exports.getAssertionState = getAssertionState;
52
+ /**
53
+ * Check the test suite internal state
54
+ *
55
+ * @example Usage
56
+ * ```ts ignore
57
+ * import { AssertionState } from "@std/internal";
58
+ *
59
+ * const assertionState = new AssertionState();
60
+ * ```
61
+ */
62
+ const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
63
+ class AssertionState {
64
+ constructor() {
65
+ _AssertionState_instances.add(this);
66
+ _AssertionState_state.set(this, void 0);
67
+ __classPrivateFieldSet(this, _AssertionState_state, {
68
+ assertionCount: undefined,
69
+ assertionCheck: false,
70
+ assertionTriggered: false,
71
+ assertionTriggeredCount: 0,
72
+ }, "f");
73
+ if (typeof globalThis?.addEventListener === "function") {
74
+ globalThis.addEventListener("unload", () => {
75
+ __classPrivateFieldGet(this, _AssertionState_instances, "m", _AssertionState_ensureCleanedUp).call(this);
76
+ });
77
+ }
78
+ else if (
79
+ // deno-lint-ignore no-explicit-any
80
+ typeof dntShim.dntGlobalThis?.process?.on === "function") {
81
+ // deno-lint-ignore no-explicit-any
82
+ dntShim.dntGlobalThis.process.on("exit", () => {
83
+ __classPrivateFieldGet(this, _AssertionState_instances, "m", _AssertionState_ensureCleanedUp).call(this);
84
+ });
85
+ }
86
+ else {
87
+ // deno-lint-ignore no-console
88
+ console.warn("AssertionCounter cleanup step was not registered");
89
+ }
90
+ }
91
+ /**
92
+ * Get the number that through `expect.assertions` api set.
93
+ *
94
+ * @returns the number that through `expect.assertions` api set.
95
+ *
96
+ * @example Usage
97
+ * ```ts ignore
98
+ * import { AssertionState } from "@std/internal";
99
+ *
100
+ * const assertionState = new AssertionState();
101
+ * assertionState.assertionCount;
102
+ * ```
103
+ */
104
+ get assertionCount() {
105
+ return __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount;
106
+ }
107
+ /**
108
+ * Get a certain number that assertions were called before.
109
+ *
110
+ * @returns return a certain number that assertions were called before.
111
+ *
112
+ * @example Usage
113
+ * ```ts ignore
114
+ * import { AssertionState } from "@std/internal";
115
+ *
116
+ * const assertionState = new AssertionState();
117
+ * assertionState.assertionTriggeredCount;
118
+ * ```
119
+ */
120
+ get assertionTriggeredCount() {
121
+ return __classPrivateFieldGet(this, _AssertionState_state, "f").assertionTriggeredCount;
122
+ }
123
+ /**
124
+ * If `expect.hasAssertions` called, then through this method to update #state.assertionCheck value.
125
+ *
126
+ * @param val Set #state.assertionCheck's value
127
+ *
128
+ * @example Usage
129
+ * ```ts ignore
130
+ * import { AssertionState } from "@std/internal";
131
+ *
132
+ * const assertionState = new AssertionState();
133
+ * assertionState.setAssertionCheck(true);
134
+ * ```
135
+ */
136
+ setAssertionCheck(val) {
137
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCheck = val;
138
+ }
139
+ /**
140
+ * If any matchers was called, `#state.assertionTriggered` will be set through this method.
141
+ *
142
+ * @param val Set #state.assertionTriggered's value
143
+ *
144
+ * @example Usage
145
+ * ```ts ignore
146
+ * import { AssertionState } from "@std/internal";
147
+ *
148
+ * const assertionState = new AssertionState();
149
+ * assertionState.setAssertionTriggered(true);
150
+ * ```
151
+ */
152
+ setAssertionTriggered(val) {
153
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionTriggered = val;
154
+ }
155
+ /**
156
+ * If `expect.assertions` called, then through this method to update #state.assertionCheck value.
157
+ *
158
+ * @param num Set #state.assertionCount's value, for example if the value is set 2, that means
159
+ * you must have two assertion matchers call in your test suite.
160
+ *
161
+ * @example Usage
162
+ * ```ts ignore
163
+ * import { AssertionState } from "@std/internal";
164
+ *
165
+ * const assertionState = new AssertionState();
166
+ * assertionState.setAssertionCount(2);
167
+ * ```
168
+ */
169
+ setAssertionCount(num) {
170
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount = num;
171
+ }
172
+ /**
173
+ * If any matchers was called, `#state.assertionTriggeredCount` value will plus one internally.
174
+ *
175
+ * @example Usage
176
+ * ```ts ignore
177
+ * import { AssertionState } from "@std/internal";
178
+ *
179
+ * const assertionState = new AssertionState();
180
+ * assertionState.updateAssertionTriggerCount();
181
+ * ```
182
+ */
183
+ updateAssertionTriggerCount() {
184
+ if (__classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount !== undefined) {
185
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionTriggeredCount += 1;
186
+ }
187
+ }
188
+ /**
189
+ * Check Assertion internal state, if `#state.assertionCheck` is set true, but
190
+ * `#state.assertionTriggered` is still false, then should throw an Assertion Error.
191
+ *
192
+ * @returns a boolean value, that the test suite is satisfied with the check. If not,
193
+ * it should throw an AssertionError.
194
+ *
195
+ * @example Usage
196
+ * ```ts ignore
197
+ * import { AssertionState } from "@std/internal";
198
+ *
199
+ * const assertionState = new AssertionState();
200
+ * if (assertionState.checkAssertionErrorState()) {
201
+ * // throw AssertionError("");
202
+ * }
203
+ * ```
204
+ */
205
+ checkAssertionErrorState() {
206
+ return __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCheck && !__classPrivateFieldGet(this, _AssertionState_state, "f").assertionTriggered;
207
+ }
208
+ /**
209
+ * Reset all assertion state when every test suite function ran completely.
210
+ *
211
+ * @example Usage
212
+ * ```ts ignore
213
+ * import { AssertionState } from "@std/internal";
214
+ *
215
+ * const assertionState = new AssertionState();
216
+ * assertionState.resetAssertionState();
217
+ * ```
218
+ */
219
+ resetAssertionState() {
220
+ __classPrivateFieldSet(this, _AssertionState_state, {
221
+ assertionCount: undefined,
222
+ assertionCheck: false,
223
+ assertionTriggered: false,
224
+ assertionTriggeredCount: 0,
225
+ }, "f");
226
+ }
227
+ /**
228
+ * Check Assertion called state, if `#state.assertionCount` is set to a number value, but
229
+ * `#state.assertionTriggeredCount` is less then it, then should throw an assertion error.
230
+ *
231
+ * @returns a boolean value, that the test suite is satisfied with the check. If not,
232
+ * it should throw an AssertionError.
233
+ *
234
+ * @example Usage
235
+ * ```ts ignore
236
+ * import { AssertionState } from "@std/internal";
237
+ *
238
+ * const assertionState = new AssertionState();
239
+ * if (assertionState.checkAssertionCountSatisfied()) {
240
+ * // throw AssertionError("");
241
+ * }
242
+ * ```
243
+ */
244
+ checkAssertionCountSatisfied() {
245
+ return __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount !== undefined &&
246
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount !== __classPrivateFieldGet(this, _AssertionState_state, "f").assertionTriggeredCount;
247
+ }
248
+ }
249
+ exports.AssertionState = AssertionState;
250
+ _AssertionState_state = new WeakMap(), _AssertionState_instances = new WeakSet(), _AssertionState_ensureCleanedUp = function _AssertionState_ensureCleanedUp() {
251
+ // If any checks were registered, after the test suite runs the checks,
252
+ // `resetAssertionState` should also have been called. If it was not,
253
+ // then the test suite did not run the checks.
254
+ if (__classPrivateFieldGet(this, _AssertionState_state, "f").assertionCheck ||
255
+ __classPrivateFieldGet(this, _AssertionState_state, "f").assertionCount !== undefined) {
256
+ throw new Error("AssertionCounter was not cleaned up: If tests are not otherwise failing, ensure `expect.hasAssertion` and `expect.assertions` are only run in bdd tests");
257
+ }
258
+ };
259
+ const assertionState = new AssertionState();
260
+ /**
261
+ * return an instance of AssertionState
262
+ *
263
+ * @returns AssertionState
264
+ *
265
+ * @example Usage
266
+ * ```ts ignore
267
+ * import { getAssertionState } from "@std/internal";
268
+ *
269
+ * const assertionState = getAssertionState();
270
+ * assertionState.setAssertionTriggered(true);
271
+ * ```
272
+ */
273
+ function getAssertionState() {
274
+ return assertionState;
275
+ }