@logixjs/test 0.0.1
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/dist/Assertions-OpNAhiI_.d.ts +16 -0
- package/dist/Assertions-uDVCBadW.d.cts +16 -0
- package/dist/Assertions.cjs +85 -0
- package/dist/Assertions.d.cts +4 -0
- package/dist/Assertions.d.ts +4 -0
- package/dist/Assertions.js +12 -0
- package/dist/Execution-Cu-n-UYb.d.ts +18 -0
- package/dist/Execution-FfEGGSS7.d.cts +18 -0
- package/dist/Execution.cjs +98 -0
- package/dist/Execution.d.cts +2 -0
- package/dist/Execution.d.ts +2 -0
- package/dist/Execution.js +24 -0
- package/dist/ExecutionResult-BRC-Jzsv.d.cts +35 -0
- package/dist/ExecutionResult-BRC-Jzsv.d.ts +35 -0
- package/dist/TestProgram-BLXiWhJQ.d.cts +31 -0
- package/dist/TestProgram-CPvVAbfI.d.cts +10 -0
- package/dist/TestProgram-DJAm0dIS.d.ts +10 -0
- package/dist/TestProgram-X35n_2Js.d.ts +31 -0
- package/dist/TestProgram.cjs +220 -0
- package/dist/TestProgram.d.cts +6 -0
- package/dist/TestProgram.d.ts +6 -0
- package/dist/TestProgram.js +10 -0
- package/dist/TestRuntime-CyYCUXdT.d.cts +10 -0
- package/dist/TestRuntime-CyYCUXdT.d.ts +10 -0
- package/dist/TestRuntime.cjs +36 -0
- package/dist/TestRuntime.d.cts +2 -0
- package/dist/TestRuntime.d.ts +2 -0
- package/dist/TestRuntime.js +8 -0
- package/dist/Vitest-BXBtxem-.d.ts +28 -0
- package/dist/Vitest-BiBMIx3C.d.cts +28 -0
- package/dist/Vitest.cjs +3338 -0
- package/dist/Vitest.d.cts +7 -0
- package/dist/Vitest.d.ts +7 -0
- package/dist/Vitest.js +13 -0
- package/dist/chunk-42QGM623.js +16 -0
- package/dist/chunk-5XFEOVH5.js +16 -0
- package/dist/chunk-CZJ37XWT.js +132 -0
- package/dist/chunk-DKT5EFOF.js +10 -0
- package/dist/chunk-DU6VSL4D.js +57 -0
- package/dist/chunk-FOYMJMJR.js +38 -0
- package/dist/chunk-J5AZHNSA.js +32 -0
- package/dist/chunk-RG24KSEB.js +64 -0
- package/dist/chunk-TDYES47J.js +3125 -0
- package/dist/chunk-WVD5DTP4.js +20 -0
- package/dist/index.cjs +3424 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +27 -0
- package/dist/magic-string.es-6HF3TVF6.js +1308 -0
- package/dist/waitUntil-CjpwZxCu.d.cts +13 -0
- package/dist/waitUntil-CjpwZxCu.d.ts +13 -0
- package/package.json +71 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.js';
|
|
4
|
+
|
|
5
|
+
declare const assertState: <Sh extends Logix.AnyModuleShape>(actual: Logix.StateOf<Sh>, predicate: (s: Logix.StateOf<Sh>) => boolean, message?: string) => Effect.Effect<void, Error>;
|
|
6
|
+
declare const assertSignal: (actual: unknown, expectedType: string, expectedPayload?: unknown) => Effect.Effect<void, Error>;
|
|
7
|
+
|
|
8
|
+
declare const Assertions_WaitUntilOptions: typeof WaitUntilOptions;
|
|
9
|
+
declare const Assertions_assertSignal: typeof assertSignal;
|
|
10
|
+
declare const Assertions_assertState: typeof assertState;
|
|
11
|
+
declare const Assertions_waitUntil: typeof waitUntil;
|
|
12
|
+
declare namespace Assertions {
|
|
13
|
+
export { Assertions_WaitUntilOptions as WaitUntilOptions, Assertions_assertSignal as assertSignal, Assertions_assertState as assertState, Assertions_waitUntil as waitUntil };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { Assertions as A, assertSignal as a, assertState as b };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { W as WaitUntilOptions, w as waitUntil } from './waitUntil-CjpwZxCu.cjs';
|
|
4
|
+
|
|
5
|
+
declare const assertState: <Sh extends Logix.AnyModuleShape>(actual: Logix.StateOf<Sh>, predicate: (s: Logix.StateOf<Sh>) => boolean, message?: string) => Effect.Effect<void, Error>;
|
|
6
|
+
declare const assertSignal: (actual: unknown, expectedType: string, expectedPayload?: unknown) => Effect.Effect<void, Error>;
|
|
7
|
+
|
|
8
|
+
declare const Assertions_WaitUntilOptions: typeof WaitUntilOptions;
|
|
9
|
+
declare const Assertions_assertSignal: typeof assertSignal;
|
|
10
|
+
declare const Assertions_assertState: typeof assertState;
|
|
11
|
+
declare const Assertions_waitUntil: typeof waitUntil;
|
|
12
|
+
declare namespace Assertions {
|
|
13
|
+
export { Assertions_WaitUntilOptions as WaitUntilOptions, Assertions_assertSignal as assertSignal, Assertions_assertState as assertState, Assertions_waitUntil as waitUntil };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { Assertions as A, assertSignal as a, assertState as b };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/Assertions.ts
|
|
21
|
+
var Assertions_exports = {};
|
|
22
|
+
__export(Assertions_exports, {
|
|
23
|
+
assertSignal: () => assertSignal,
|
|
24
|
+
assertState: () => assertState,
|
|
25
|
+
waitUntil: () => waitUntil
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(Assertions_exports);
|
|
28
|
+
|
|
29
|
+
// src/internal/utils/assertions.ts
|
|
30
|
+
var import_effect = require("effect");
|
|
31
|
+
var assertState = (actual, predicate, message) => {
|
|
32
|
+
return import_effect.Effect.suspend(() => {
|
|
33
|
+
if (predicate(actual)) {
|
|
34
|
+
return import_effect.Effect.void;
|
|
35
|
+
}
|
|
36
|
+
return import_effect.Effect.fail(new Error(message || `State assertion failed. Actual: ${JSON.stringify(actual)}`));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var assertSignal = (actual, expectedType, expectedPayload) => {
|
|
40
|
+
return import_effect.Effect.suspend(() => {
|
|
41
|
+
const candidate = actual;
|
|
42
|
+
if (candidate && typeof candidate === "object" && typeof candidate._tag === "string" && candidate._tag === expectedType) {
|
|
43
|
+
if (expectedPayload !== void 0) {
|
|
44
|
+
if (import_effect.Equal.equals(candidate.payload, expectedPayload)) {
|
|
45
|
+
return import_effect.Effect.void;
|
|
46
|
+
}
|
|
47
|
+
return import_effect.Effect.fail(
|
|
48
|
+
new Error(
|
|
49
|
+
`Signal payload mismatch. Expected: ${JSON.stringify(expectedPayload)}, Actual: ${JSON.stringify(
|
|
50
|
+
candidate.payload
|
|
51
|
+
)}`
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return import_effect.Effect.void;
|
|
56
|
+
}
|
|
57
|
+
return import_effect.Effect.fail(
|
|
58
|
+
new Error(`Signal assertion failed. Expected type: ${expectedType}, Actual: ${JSON.stringify(actual)}`)
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// src/internal/utils/waitUntil.ts
|
|
64
|
+
var import_effect2 = require("effect");
|
|
65
|
+
var waitUntil = (check, options = {}) => import_effect2.Effect.gen(function* () {
|
|
66
|
+
const maxAttempts = options.maxAttempts ?? 20;
|
|
67
|
+
const step = options.step ?? "10 millis";
|
|
68
|
+
let lastError;
|
|
69
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
70
|
+
const result = yield* check.pipe(import_effect2.Effect.exit);
|
|
71
|
+
if (result._tag === "Success") {
|
|
72
|
+
return result.value;
|
|
73
|
+
}
|
|
74
|
+
lastError = result.cause;
|
|
75
|
+
yield* import_effect2.TestClock.adjust(step);
|
|
76
|
+
yield* import_effect2.Effect.yieldNow();
|
|
77
|
+
}
|
|
78
|
+
return yield* import_effect2.Effect.fail(lastError);
|
|
79
|
+
});
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
assertSignal,
|
|
83
|
+
assertState,
|
|
84
|
+
waitUntil
|
|
85
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { E as ExecutionResult, T as TraceEvent, e as expectActionSequence, a as expectActionTag, b as expectNoActionTag, c as expectNoError, g as getActionsByTag, d as getErrors, h as hasAction, f as hasError, m as make } from './ExecutionResult-BRC-Jzsv.js';
|
|
2
|
+
|
|
3
|
+
declare const Execution_ExecutionResult: typeof ExecutionResult;
|
|
4
|
+
declare const Execution_TraceEvent: typeof TraceEvent;
|
|
5
|
+
declare const Execution_expectActionSequence: typeof expectActionSequence;
|
|
6
|
+
declare const Execution_expectActionTag: typeof expectActionTag;
|
|
7
|
+
declare const Execution_expectNoActionTag: typeof expectNoActionTag;
|
|
8
|
+
declare const Execution_expectNoError: typeof expectNoError;
|
|
9
|
+
declare const Execution_getActionsByTag: typeof getActionsByTag;
|
|
10
|
+
declare const Execution_getErrors: typeof getErrors;
|
|
11
|
+
declare const Execution_hasAction: typeof hasAction;
|
|
12
|
+
declare const Execution_hasError: typeof hasError;
|
|
13
|
+
declare const Execution_make: typeof make;
|
|
14
|
+
declare namespace Execution {
|
|
15
|
+
export { Execution_ExecutionResult as ExecutionResult, Execution_TraceEvent as TraceEvent, Execution_expectActionSequence as expectActionSequence, Execution_expectActionTag as expectActionTag, Execution_expectNoActionTag as expectNoActionTag, Execution_expectNoError as expectNoError, Execution_getActionsByTag as getActionsByTag, Execution_getErrors as getErrors, Execution_hasAction as hasAction, Execution_hasError as hasError, Execution_make as make };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Execution as E };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { E as ExecutionResult, T as TraceEvent, e as expectActionSequence, a as expectActionTag, b as expectNoActionTag, c as expectNoError, g as getActionsByTag, d as getErrors, h as hasAction, f as hasError, m as make } from './ExecutionResult-BRC-Jzsv.cjs';
|
|
2
|
+
|
|
3
|
+
declare const Execution_ExecutionResult: typeof ExecutionResult;
|
|
4
|
+
declare const Execution_TraceEvent: typeof TraceEvent;
|
|
5
|
+
declare const Execution_expectActionSequence: typeof expectActionSequence;
|
|
6
|
+
declare const Execution_expectActionTag: typeof expectActionTag;
|
|
7
|
+
declare const Execution_expectNoActionTag: typeof expectNoActionTag;
|
|
8
|
+
declare const Execution_expectNoError: typeof expectNoError;
|
|
9
|
+
declare const Execution_getActionsByTag: typeof getActionsByTag;
|
|
10
|
+
declare const Execution_getErrors: typeof getErrors;
|
|
11
|
+
declare const Execution_hasAction: typeof hasAction;
|
|
12
|
+
declare const Execution_hasError: typeof hasError;
|
|
13
|
+
declare const Execution_make: typeof make;
|
|
14
|
+
declare namespace Execution {
|
|
15
|
+
export { Execution_ExecutionResult as ExecutionResult, Execution_TraceEvent as TraceEvent, Execution_expectActionSequence as expectActionSequence, Execution_expectActionTag as expectActionTag, Execution_expectNoActionTag as expectNoActionTag, Execution_expectNoError as expectNoError, Execution_getActionsByTag as getActionsByTag, Execution_getErrors as getErrors, Execution_hasAction as hasAction, Execution_hasError as hasError, Execution_make as make };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Execution as E };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/Execution.ts
|
|
21
|
+
var Execution_exports = {};
|
|
22
|
+
__export(Execution_exports, {
|
|
23
|
+
expectActionSequence: () => expectActionSequence,
|
|
24
|
+
expectActionTag: () => expectActionTag,
|
|
25
|
+
expectNoActionTag: () => expectNoActionTag,
|
|
26
|
+
expectNoError: () => expectNoError,
|
|
27
|
+
getActionsByTag: () => getActionsByTag,
|
|
28
|
+
getErrors: () => getErrors,
|
|
29
|
+
hasAction: () => hasAction,
|
|
30
|
+
hasError: () => hasError,
|
|
31
|
+
make: () => make
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Execution_exports);
|
|
34
|
+
|
|
35
|
+
// src/internal/api/ExecutionResult.ts
|
|
36
|
+
var make = (state, actions, trace) => ({
|
|
37
|
+
state,
|
|
38
|
+
actions,
|
|
39
|
+
trace
|
|
40
|
+
});
|
|
41
|
+
var hasAction = (result, predicate) => result.actions.some(predicate);
|
|
42
|
+
var getActionsByTag = (result, tag) => result.actions.filter((action) => typeof action._tag === "string" && action._tag === tag);
|
|
43
|
+
var hasError = (result) => result.trace.some((event) => event._tag === "Error");
|
|
44
|
+
var getErrors = (result) => result.trace.filter((event) => event._tag === "Error");
|
|
45
|
+
var actionTagOf = (action) => {
|
|
46
|
+
const value = action;
|
|
47
|
+
if (typeof value?._tag === "string") {
|
|
48
|
+
return value._tag;
|
|
49
|
+
}
|
|
50
|
+
if (typeof value?.type === "string") {
|
|
51
|
+
return value.type;
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
};
|
|
55
|
+
var expectActionTag = (result, tag, options = {}) => {
|
|
56
|
+
const actions = getActionsByTag(result, tag);
|
|
57
|
+
if (actions.length === 0) {
|
|
58
|
+
throw new Error(`Expected at least one action with tag "${tag}", but found none.`);
|
|
59
|
+
}
|
|
60
|
+
if (options.times !== void 0 && actions.length !== options.times) {
|
|
61
|
+
throw new Error(`Expected ${options.times} actions with tag "${tag}", but found ${actions.length}.`);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var expectNoActionTag = (result, tag) => {
|
|
65
|
+
const actions = getActionsByTag(result, tag);
|
|
66
|
+
if (actions.length > 0) {
|
|
67
|
+
throw new Error(`Expected no actions with tag "${tag}", but found ${actions.length}.`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var expectActionSequence = (result, tags) => {
|
|
71
|
+
const actualTags = result.actions.map((action) => actionTagOf(action)).filter((tag) => typeof tag === "string");
|
|
72
|
+
if (actualTags.length !== tags.length) {
|
|
73
|
+
throw new Error(`Expected action tag sequence [${tags.join(", ")}], but got [${actualTags.join(", ")}].`);
|
|
74
|
+
}
|
|
75
|
+
for (let i = 0; i < tags.length; i++) {
|
|
76
|
+
if (actualTags[i] !== tags[i]) {
|
|
77
|
+
throw new Error(`Expected action tag sequence [${tags.join(", ")}], but got [${actualTags.join(", ")}].`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var expectNoError = (result) => {
|
|
82
|
+
const errors = getErrors(result);
|
|
83
|
+
if (errors.length > 0) {
|
|
84
|
+
throw new Error(`Expected no errors, but found ${errors.length}. First error cause: ${String(errors[0]?.cause)}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
expectActionSequence,
|
|
90
|
+
expectActionTag,
|
|
91
|
+
expectNoActionTag,
|
|
92
|
+
expectNoError,
|
|
93
|
+
getActionsByTag,
|
|
94
|
+
getErrors,
|
|
95
|
+
hasAction,
|
|
96
|
+
hasError,
|
|
97
|
+
make
|
|
98
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { E as ExecutionResult, T as TraceEvent, e as expectActionSequence, a as expectActionTag, b as expectNoActionTag, c as expectNoError, g as getActionsByTag, d as getErrors, h as hasAction, f as hasError, m as make } from './ExecutionResult-BRC-Jzsv.cjs';
|
|
2
|
+
import '@logixjs/core';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { E as ExecutionResult, T as TraceEvent, e as expectActionSequence, a as expectActionTag, b as expectNoActionTag, c as expectNoError, g as getActionsByTag, d as getErrors, h as hasAction, f as hasError, m as make } from './ExecutionResult-BRC-Jzsv.js';
|
|
2
|
+
import '@logixjs/core';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./chunk-J5AZHNSA.js";
|
|
2
|
+
import {
|
|
3
|
+
expectActionSequence,
|
|
4
|
+
expectActionTag,
|
|
5
|
+
expectNoActionTag,
|
|
6
|
+
expectNoError,
|
|
7
|
+
getActionsByTag,
|
|
8
|
+
getErrors,
|
|
9
|
+
hasAction,
|
|
10
|
+
hasError,
|
|
11
|
+
make
|
|
12
|
+
} from "./chunk-RG24KSEB.js";
|
|
13
|
+
import "./chunk-FOYMJMJR.js";
|
|
14
|
+
export {
|
|
15
|
+
expectActionSequence,
|
|
16
|
+
expectActionTag,
|
|
17
|
+
expectNoActionTag,
|
|
18
|
+
expectNoError,
|
|
19
|
+
getActionsByTag,
|
|
20
|
+
getErrors,
|
|
21
|
+
hasAction,
|
|
22
|
+
hasError,
|
|
23
|
+
make
|
|
24
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Logix from '@logixjs/core';
|
|
2
|
+
|
|
3
|
+
interface ExecutionResult<Sh extends Logix.AnyModuleShape> {
|
|
4
|
+
readonly trace: ReadonlyArray<TraceEvent<Sh>>;
|
|
5
|
+
readonly state: Logix.StateOf<Sh>;
|
|
6
|
+
readonly actions: ReadonlyArray<Logix.ActionOf<Sh>>;
|
|
7
|
+
}
|
|
8
|
+
type TraceEvent<Sh extends Logix.AnyModuleShape> = {
|
|
9
|
+
_tag: 'Action';
|
|
10
|
+
action: Logix.ActionOf<Sh>;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
} | {
|
|
13
|
+
_tag: 'State';
|
|
14
|
+
state: Logix.StateOf<Sh>;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
} | {
|
|
17
|
+
_tag: 'Error';
|
|
18
|
+
cause: unknown;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
};
|
|
21
|
+
declare const make: <Sh extends Logix.AnyModuleShape>(state: Logix.StateOf<Sh>, actions: ReadonlyArray<Logix.ActionOf<Sh>>, trace: ReadonlyArray<TraceEvent<Sh>>) => ExecutionResult<Sh>;
|
|
22
|
+
declare const hasAction: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, predicate: (action: Logix.ActionOf<Sh>) => boolean) => boolean;
|
|
23
|
+
declare const getActionsByTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string) => ReadonlyArray<Logix.ActionOf<Sh>>;
|
|
24
|
+
declare const hasError: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => boolean;
|
|
25
|
+
declare const getErrors: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => ReadonlyArray<Extract<TraceEvent<Sh>, {
|
|
26
|
+
_tag: "Error";
|
|
27
|
+
}>>;
|
|
28
|
+
declare const expectActionTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string, options?: {
|
|
29
|
+
readonly times?: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
declare const expectNoActionTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string) => void;
|
|
32
|
+
declare const expectActionSequence: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tags: ReadonlyArray<string>) => void;
|
|
33
|
+
declare const expectNoError: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => void;
|
|
34
|
+
|
|
35
|
+
export { type ExecutionResult as E, type TraceEvent as T, expectActionTag as a, expectNoActionTag as b, expectNoError as c, getErrors as d, expectActionSequence as e, hasError as f, getActionsByTag as g, hasAction as h, make as m };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Logix from '@logixjs/core';
|
|
2
|
+
|
|
3
|
+
interface ExecutionResult<Sh extends Logix.AnyModuleShape> {
|
|
4
|
+
readonly trace: ReadonlyArray<TraceEvent<Sh>>;
|
|
5
|
+
readonly state: Logix.StateOf<Sh>;
|
|
6
|
+
readonly actions: ReadonlyArray<Logix.ActionOf<Sh>>;
|
|
7
|
+
}
|
|
8
|
+
type TraceEvent<Sh extends Logix.AnyModuleShape> = {
|
|
9
|
+
_tag: 'Action';
|
|
10
|
+
action: Logix.ActionOf<Sh>;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
} | {
|
|
13
|
+
_tag: 'State';
|
|
14
|
+
state: Logix.StateOf<Sh>;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
} | {
|
|
17
|
+
_tag: 'Error';
|
|
18
|
+
cause: unknown;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
};
|
|
21
|
+
declare const make: <Sh extends Logix.AnyModuleShape>(state: Logix.StateOf<Sh>, actions: ReadonlyArray<Logix.ActionOf<Sh>>, trace: ReadonlyArray<TraceEvent<Sh>>) => ExecutionResult<Sh>;
|
|
22
|
+
declare const hasAction: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, predicate: (action: Logix.ActionOf<Sh>) => boolean) => boolean;
|
|
23
|
+
declare const getActionsByTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string) => ReadonlyArray<Logix.ActionOf<Sh>>;
|
|
24
|
+
declare const hasError: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => boolean;
|
|
25
|
+
declare const getErrors: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => ReadonlyArray<Extract<TraceEvent<Sh>, {
|
|
26
|
+
_tag: "Error";
|
|
27
|
+
}>>;
|
|
28
|
+
declare const expectActionTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string, options?: {
|
|
29
|
+
readonly times?: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
declare const expectNoActionTag: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tag: string) => void;
|
|
32
|
+
declare const expectActionSequence: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>, tags: ReadonlyArray<string>) => void;
|
|
33
|
+
declare const expectNoError: <Sh extends Logix.AnyModuleShape>(result: ExecutionResult<Sh>) => void;
|
|
34
|
+
|
|
35
|
+
export { type ExecutionResult as E, type TraceEvent as T, expectActionTag as a, expectNoActionTag as b, expectNoError as c, getErrors as d, expectActionSequence as e, hasError as f, getActionsByTag as g, hasAction as h, make as m };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Effect, Duration, TestClock, Scope } from 'effect';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { AnyModuleShape } from '@logixjs/core';
|
|
4
|
+
import { ProgramRunContext, OpenProgramOptions } from '@logixjs/core/Runtime';
|
|
5
|
+
import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.cjs';
|
|
6
|
+
import { W as WaitUntilOptions } from './waitUntil-CjpwZxCu.cjs';
|
|
7
|
+
|
|
8
|
+
interface TestApi<Sh extends Logix.AnyModuleShape> {
|
|
9
|
+
readonly ctx: ProgramRunContext<Sh>;
|
|
10
|
+
readonly dispatch: (action: Logix.ActionOf<Sh>) => Effect.Effect<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Advances the test clock (must run under TestContext).
|
|
13
|
+
*
|
|
14
|
+
* Notes:
|
|
15
|
+
* - For logic that depends on `Effect.sleep` / `Schedule.addDelay`, you must explicitly advance TestClock
|
|
16
|
+
* for time to move forward.
|
|
17
|
+
* - The runner does not implicitly keep-alive / auto-advance time, keeping time semantics controllable and explainable.
|
|
18
|
+
*/
|
|
19
|
+
readonly advance: (duration: Duration.DurationInput) => Effect.Effect<void, never, TestClock.TestClock>;
|
|
20
|
+
readonly assert: {
|
|
21
|
+
readonly state: (predicate: (s: Logix.StateOf<Sh>) => boolean, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
|
|
22
|
+
readonly signal: (expectedType: string, expectedPayload?: unknown, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type TestProgramOptions = Omit<OpenProgramOptions, 'handleSignals'> & {
|
|
27
|
+
readonly handleSignals?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const runProgram: <Sh extends AnyModuleShape>(program: Logix.ModuleImpl<any, Sh, any> | Logix.AnyModule, body: (api: TestApi<Sh>) => Effect.Effect<void, any, any>, options?: TestProgramOptions) => Effect.Effect<ExecutionResult<Sh>, unknown, Scope.Scope>;
|
|
30
|
+
|
|
31
|
+
export { type TestApi as T, type TestProgramOptions as a, runProgram as r };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-BLXiWhJQ.cjs';
|
|
2
|
+
|
|
3
|
+
declare const TestProgram_TestApi: typeof TestApi;
|
|
4
|
+
declare const TestProgram_TestProgramOptions: typeof TestProgramOptions;
|
|
5
|
+
declare const TestProgram_runProgram: typeof runProgram;
|
|
6
|
+
declare namespace TestProgram {
|
|
7
|
+
export { TestProgram_TestApi as TestApi, TestProgram_TestProgramOptions as TestProgramOptions, TestProgram_runProgram as runProgram };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { TestProgram as T };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { T as TestApi, a as TestProgramOptions, r as runProgram } from './TestProgram-X35n_2Js.js';
|
|
2
|
+
|
|
3
|
+
declare const TestProgram_TestApi: typeof TestApi;
|
|
4
|
+
declare const TestProgram_TestProgramOptions: typeof TestProgramOptions;
|
|
5
|
+
declare const TestProgram_runProgram: typeof runProgram;
|
|
6
|
+
declare namespace TestProgram {
|
|
7
|
+
export { TestProgram_TestApi as TestApi, TestProgram_TestProgramOptions as TestProgramOptions, TestProgram_runProgram as runProgram };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { TestProgram as T };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Effect, Duration, TestClock, Scope } from 'effect';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { AnyModuleShape } from '@logixjs/core';
|
|
4
|
+
import { ProgramRunContext, OpenProgramOptions } from '@logixjs/core/Runtime';
|
|
5
|
+
import { E as ExecutionResult } from './ExecutionResult-BRC-Jzsv.js';
|
|
6
|
+
import { W as WaitUntilOptions } from './waitUntil-CjpwZxCu.js';
|
|
7
|
+
|
|
8
|
+
interface TestApi<Sh extends Logix.AnyModuleShape> {
|
|
9
|
+
readonly ctx: ProgramRunContext<Sh>;
|
|
10
|
+
readonly dispatch: (action: Logix.ActionOf<Sh>) => Effect.Effect<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Advances the test clock (must run under TestContext).
|
|
13
|
+
*
|
|
14
|
+
* Notes:
|
|
15
|
+
* - For logic that depends on `Effect.sleep` / `Schedule.addDelay`, you must explicitly advance TestClock
|
|
16
|
+
* for time to move forward.
|
|
17
|
+
* - The runner does not implicitly keep-alive / auto-advance time, keeping time semantics controllable and explainable.
|
|
18
|
+
*/
|
|
19
|
+
readonly advance: (duration: Duration.DurationInput) => Effect.Effect<void, never, TestClock.TestClock>;
|
|
20
|
+
readonly assert: {
|
|
21
|
+
readonly state: (predicate: (s: Logix.StateOf<Sh>) => boolean, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
|
|
22
|
+
readonly signal: (expectedType: string, expectedPayload?: unknown, options?: WaitUntilOptions) => Effect.Effect<void, Error, TestClock.TestClock>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type TestProgramOptions = Omit<OpenProgramOptions, 'handleSignals'> & {
|
|
27
|
+
readonly handleSignals?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const runProgram: <Sh extends AnyModuleShape>(program: Logix.ModuleImpl<any, Sh, any> | Logix.AnyModule, body: (api: TestApi<Sh>) => Effect.Effect<void, any, any>, options?: TestProgramOptions) => Effect.Effect<ExecutionResult<Sh>, unknown, Scope.Scope>;
|
|
30
|
+
|
|
31
|
+
export { type TestApi as T, type TestProgramOptions as a, runProgram as r };
|