@kairos-es/testing 1.0.0-alpha.4 → 1.0.0-alpha.6
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/README.md +1 -4
- package/dist/cjs/specification.js +2 -2
- package/dist/cjs/specification.js.map +1 -1
- package/dist/dts-cjs/package.json +3 -0
- package/dist/dts-cjs/specification.d.ts.map +1 -0
- package/dist/dts-esm/index.d.ts +31 -0
- package/dist/dts-esm/index.d.ts.map +1 -0
- package/dist/dts-esm/package.json +3 -0
- package/dist/dts-esm/specification.d.ts +141 -0
- package/dist/dts-esm/specification.d.ts.map +1 -0
- package/dist/esm/specification.js +3 -3
- package/dist/esm/specification.js.map +1 -1
- package/package.json +14 -9
- package/src/specification.ts +3 -12
- package/dist/dts/specification.d.ts.map +0 -1
- /package/dist/{dts → dts-cjs}/index.d.ts +0 -0
- /package/dist/{dts → dts-cjs}/index.d.ts.map +0 -0
- /package/dist/{dts → dts-cjs}/specification.d.ts +0 -0
package/README.md
CHANGED
|
@@ -8,12 +8,9 @@ A **development** dependency: it peers `@effect/vitest` and is imported from
|
|
|
8
8
|
tests only.
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
pnpm add -D @kairos-es/testing@alpha @effect/vitest@^0.
|
|
11
|
+
pnpm add -D @kairos-es/testing@alpha @effect/vitest@^4.0.5 vitest@^5.0.4
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
`vitest` is named because `@effect/vitest` requires it and pnpm does not install
|
|
15
|
-
a peer for you.
|
|
16
|
-
|
|
17
14
|
Its other peers, `@kairos-es/core`, `@kairos-es/codec` and `effect`, are the ones
|
|
18
15
|
an application using the library already has.
|
|
19
16
|
|
|
@@ -64,7 +64,7 @@ const shapeOf = event => ({
|
|
|
64
64
|
data: event.data
|
|
65
65
|
});
|
|
66
66
|
/** Collect a stream of sequenced events into a plain array. */
|
|
67
|
-
const collect = events => _effect.Stream.runCollect(events)
|
|
67
|
+
const collect = events => _effect.Stream.runCollect(events);
|
|
68
68
|
/**
|
|
69
69
|
* Seed the given past-event producers into the store: materialise each producer
|
|
70
70
|
* (encode -> serialise), then one append each (log order). Returns the position
|
|
@@ -150,7 +150,7 @@ const specificationForCycle = run => ({
|
|
|
150
150
|
const exit = yield* runToExit;
|
|
151
151
|
(0, _vitest.expect)(_effect.Exit.isFailure(exit)).toBe(true);
|
|
152
152
|
if (_effect.Exit.isFailure(exit)) {
|
|
153
|
-
const failure = _effect.Cause.
|
|
153
|
+
const failure = _effect.Cause.findErrorOption(exit.cause);
|
|
154
154
|
const error = failure._tag === 'Some' ? failure.value : undefined;
|
|
155
155
|
const actualTag = typeof error === 'object' && error !== null && '_tag' in error ? error._tag : undefined;
|
|
156
156
|
(0, _vitest.expect)(actualTag).toBe(tag);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specification.js","names":["_vitest","require","_codec","_core","_effect","shapeOf","event","type","tags","data","collect","events","Stream","runCollect","
|
|
1
|
+
{"version":3,"file":"specification.js","names":["_vitest","require","_codec","_core","_effect","shapeOf","event","type","tags","data","collect","events","Stream","runCollect","seed","producers","Effect","gen","store","DcbEventStore","last","ORIGIN","producer","append","pipe","orDie","appendedAfter","after","read","Q","all","specificationForCycle","run","given","pastEvents","when","command","runToExit","zip","exit","then","expected","Exit","isFailure","failCause","cause","seedBoundary","result","value","expect","isUnchanged","toBe","appended","expectedEvents","map","s","toEqual","thenError","tag","failure","Cause","findErrorOption","error","_tag","undefined","actualTag","thenUnchanged","exports","specificationFor","decider","runDecider","scenario","description","build","it","effect","provide","Layer","mergeAll","fresh","DcbEventStoreInMemory","SerializerDefault","UuidTest"],"sources":["../../src/specification.ts"],"sourcesContent":[null],"mappings":";;;;;;AAiDA,IAAAA,OAAA,GAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AAUA,IAAAG,OAAA,GAAAH,OAAA;AA9EA;;;;;;;;;;;;;;;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AAA;AAaO,MAAMG,QAAQ,GAAGA,CAMtBC,WAAmB,EACnBH,OAAyC,EACzCI,KAE2E,KACnE;EACRC,UAAE,CAACC,MAAM,CAACH,WAAW,EAAE,MACrBC,KAAK,CAACL,gBAAgB,CAACC,OAAO,CAAC,CAAC,CAAC7C,IAAI;EACnC;EACA;EACAR,cAAM,CAAC4D,OAAO,CACZC,aAAK,CAACC,QAAQ,CACZD,aAAK,CAACE,KAAK,CAACC,2BAAqB,CAAC,EAClCC,wBAAiB,EACjBJ,aAAK,CAACE,KAAK,CAACG,eAAQ,CAAC,CACtB,CACF,CACF,CACF;AACH,CAAC;AAAAf,OAAA,CAAAI,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specification.d.ts","sourceRoot":"","sources":["../../src/specification.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,IAAI,EAEV,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,aAAa,EAGb,KAAK,QAAQ,EAGd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,KAAK,IAAI,GAAG,EAAS,MAAM,EAAuB,MAAM,QAAQ,CAAA;AAE9E,mFAAmF;AACnF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAC1C,QAAQ,EACR,UAAU,EACV,UAAU,GAAG,IAAI,GAAG,CAAC,CACtB,CAAA;AAiED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,qBAAqB,GACrB,oBAAoB,GACpB,eAAe,CAAA;AAEnB;;;;;;;;;;;;;;GAcG;AACH,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AAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kairos-es/testing — the Given/When/Then decision-model testing surface.
|
|
3
|
+
*
|
|
4
|
+
* A `DeciderSpecification`-equivalent over a real fold and a `DcbEventStore` (in
|
|
5
|
+
* practice the in-memory layer): `@kairos-es/codec`'s `buildDecisionModel` for
|
|
6
|
+
* a single-hop decision, and `modelAtHead` plus the read ledger for a layered
|
|
7
|
+
* one. Shaped so an Event Modeling `Specification` (given events / when a
|
|
8
|
+
* command / then events / thenError a tag) compiles onto it 1:1, plus
|
|
9
|
+
* `thenUnchanged` for a decision that answers "already done" and appends
|
|
10
|
+
* nothing.
|
|
11
|
+
*
|
|
12
|
+
* scenario('subscribe a student', subscribeDecider, (spec) =>
|
|
13
|
+
* spec
|
|
14
|
+
* .given(courseDefined('c1', 10))
|
|
15
|
+
* .when({ studentId: 's1', courseId: 'c1' })
|
|
16
|
+
* .then(studentSubscribed('s1', 'c1')),
|
|
17
|
+
* )
|
|
18
|
+
*
|
|
19
|
+
* The unit it exercises — `Decider`, pairing the schema-backed projections a
|
|
20
|
+
* command reads with an effectful `decide` step producing events via `toEvent`,
|
|
21
|
+
* and `runDecider`, running the real read -> decode -> decide -> append cycle —
|
|
22
|
+
* belongs to `@kairos-es/codec` and is imported from there, so the surface
|
|
23
|
+
* exercises the genuine production cycle and not a test-only restatement of it.
|
|
24
|
+
* It is deliberately NOT re-exported here: this package peers `@effect/vitest`,
|
|
25
|
+
* and a re-export would let a production command handler reach a test framework
|
|
26
|
+
* through the type it names. Given/expected events are effectful producers
|
|
27
|
+
* (`toEvent`), materialised under the same serialiser + uuid layers `scenario`
|
|
28
|
+
* provides.
|
|
29
|
+
*/
|
|
30
|
+
export * from './specification.js';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { CodecError, Decider, DecisionOutput, NoReadsRecorded, RequirementOf, SliceProjection, TaglessSliceInLedger, Unchanged } from '@kairos-es/codec';
|
|
2
|
+
import { type Serializer, type Uuid } from '@kairos-es/codec';
|
|
3
|
+
import { type AppendConditionFailed, type DcbEvent, DcbEventStore, type Position } from '@kairos-es/core';
|
|
4
|
+
import { type Array as Arr, Effect } from 'effect';
|
|
5
|
+
/** An effectful producer of a wire event (the `toEvent` result an app authors). */
|
|
6
|
+
export type EventProducer<R> = Effect.Effect<DcbEvent, CodecError, Serializer | Uuid | R>;
|
|
7
|
+
/**
|
|
8
|
+
* The errors a command CYCLE contributes, beyond whatever `E` the decision
|
|
9
|
+
* itself fails with.
|
|
10
|
+
*
|
|
11
|
+
* Named once and exported because it is what makes the layered entry point below
|
|
12
|
+
* UNIFY. `WhenSpec.then` adds this union itself, so a `run` written as a naive
|
|
13
|
+
* `Effect<Position, E, R>` double-counts every member of it and fails to
|
|
14
|
+
* typecheck against a chain that has already added them — a trap with an
|
|
15
|
+
* unhelpful error message, met once and closed here by giving the union a name a
|
|
16
|
+
* caller can write.
|
|
17
|
+
*
|
|
18
|
+
* `NoReadsRecorded` is reachable only on the layered path and `TaglessSliceInLedger`
|
|
19
|
+
* only where a bracket is open, but both are members here rather than in a second
|
|
20
|
+
* union, because the two paths share every step downstream of `when` and a second
|
|
21
|
+
* union would be a second thing to keep in step for no caller's benefit.
|
|
22
|
+
*/
|
|
23
|
+
export type CycleError = CodecError | AppendConditionFailed | TaglessSliceInLedger | NoReadsRecorded;
|
|
24
|
+
/**
|
|
25
|
+
* The entry point of the Given/When/Then chain: what `specificationFor` returns
|
|
26
|
+
* and what `scenario` hands its `build` callback. It is NAMED rather than
|
|
27
|
+
* written inline at those two sites because it was the one step of this chain
|
|
28
|
+
* with no name — the two statements of it were free to drift — and it is the
|
|
29
|
+
* step a caller most needs to name, since factoring a `build` callback out of a
|
|
30
|
+
* `scenario` call means writing its parameter's type. The sibling fluent
|
|
31
|
+
* builder in `@kairos-es/codec` names its own entry point (`ProjectionBuilder`)
|
|
32
|
+
* for the same reason.
|
|
33
|
+
*
|
|
34
|
+
* It introduces no type parameter of its own: all four are `GivenSpec`'s below,
|
|
35
|
+
* passed straight through, because seeding past events changes nothing about
|
|
36
|
+
* the command, the domain error, or either requirement — it only fixes the
|
|
37
|
+
* state the decision is folded from.
|
|
38
|
+
*/
|
|
39
|
+
export interface Specification<Command, E, R, PR> {
|
|
40
|
+
/**
|
|
41
|
+
* Seed the past events, in log order (one append each). They are effectful
|
|
42
|
+
* producers, materialised under the same layers the decision runs against.
|
|
43
|
+
*/
|
|
44
|
+
readonly given: (...pastEvents: ReadonlyArray<EventProducer<R>>) => GivenSpec<Command, E, R, PR>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A spec bound to a decider and a set of given events, awaiting `.when`. `PR` is
|
|
48
|
+
* the slices' decode requirement (`RequirementOf<P>`) that also flows through
|
|
49
|
+
* the terminals' requirement channel alongside the produce requirement `R`.
|
|
50
|
+
*/
|
|
51
|
+
export interface GivenSpec<Command, E, R, PR> {
|
|
52
|
+
/** Supply the command to decide. */
|
|
53
|
+
readonly when: (command: Command) => WhenSpec<E, R, PR>;
|
|
54
|
+
}
|
|
55
|
+
/** A spec that has a command and awaits a `then`/`thenError`/`thenUnchanged` assertion. */
|
|
56
|
+
export interface WhenSpec<E, R, PR> {
|
|
57
|
+
/**
|
|
58
|
+
* Assert the success branch: the decider appended exactly these events
|
|
59
|
+
* (compared structurally by type/tags/data, in order). The expected events are
|
|
60
|
+
* effectful producers, materialised under the provided layers. The error
|
|
61
|
+
* channel keeps `E | CycleError` because a genuinely failing cycle re-raises
|
|
62
|
+
* its cause (a `.then` on a failing decision is a test-authoring mistake, made
|
|
63
|
+
* loud rather than silently green).
|
|
64
|
+
*
|
|
65
|
+
* A cycle that answered `Unchanged` FAILS this assertion, even with no
|
|
66
|
+
* expected events. `.then()` with an empty list and `.thenUnchanged()` both
|
|
67
|
+
* see nothing appended, but they claim different things — *decided an empty
|
|
68
|
+
* change* is not a decision this library can make, while *already done* is —
|
|
69
|
+
* so the one that does not match the cycle's answer must not pass.
|
|
70
|
+
*/
|
|
71
|
+
readonly then: (...expected: ReadonlyArray<EventProducer<R>>) => Effect.Effect<void, E | CycleError, DcbEventStore | Serializer | Uuid | R | PR>;
|
|
72
|
+
/**
|
|
73
|
+
* Assert the failure branch: the cycle failed with a tagged error whose
|
|
74
|
+
* `_tag` equals `tag` (a domain error from `decide`, a `CodecError` from
|
|
75
|
+
* decode, or `AppendConditionFailed` from a moved consistency boundary).
|
|
76
|
+
*
|
|
77
|
+
* ⚠ THREE WAYS THIS PASSES FOR THE WRONG REASON, and a layered or permission
|
|
78
|
+
* suite must assert more than the tag. An opaque refusal is correct on the wire
|
|
79
|
+
* and is exactly what blinds this assertion — two different denials share one
|
|
80
|
+
* tag, so a spec can pass on a refusal its author did not mean. An
|
|
81
|
+
* `AppendConditionFailed` now also fires for an EARLIER hop, so the tag no
|
|
82
|
+
* longer says which boundary moved. And `NoReadsRecorded` is a reachable spec
|
|
83
|
+
* whose shape does not mark it as structural: it reads like a domain assertion
|
|
84
|
+
* and is a statement about wiring.
|
|
85
|
+
*/
|
|
86
|
+
readonly thenError: (tag: string) => Effect.Effect<void, never, DcbEventStore | Serializer | Uuid | R | PR>;
|
|
87
|
+
/**
|
|
88
|
+
* Assert the "already done" branch: the cycle SUCCEEDED with `Unchanged`
|
|
89
|
+
* (recognised by `isUnchanged`, never by its tag) and appended nothing past
|
|
90
|
+
* the seed. A cycle that appended — even an empty-looking one — or that
|
|
91
|
+
* returned a `Position` fails it, and a failing cycle re-raises its cause, for
|
|
92
|
+
* the reason `then` gives.
|
|
93
|
+
*
|
|
94
|
+
* Both halves are asserted, not just the result, because they are different
|
|
95
|
+
* claims: a runner that returned `Unchanged` AND appended would be exactly the
|
|
96
|
+
* defect this step exists to catch, and the result alone would not see it.
|
|
97
|
+
*/
|
|
98
|
+
readonly thenUnchanged: () => Effect.Effect<void, E | CycleError, DcbEventStore | Serializer | Uuid | R | PR>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Begin a specification for ANY command cycle that returns the appended
|
|
102
|
+
* `Position` — a bracket for one command as readily as a decider — or
|
|
103
|
+
* `Unchanged`, for a cycle that can answer "already done".
|
|
104
|
+
*
|
|
105
|
+
* This is the general form and `specificationFor` below is a one-line
|
|
106
|
+
* specialisation of it, which is the result worth stating rather than the
|
|
107
|
+
* mechanism: a `Decider` is one particular `(command) => Effect<Position, …>`,
|
|
108
|
+
* and `runDecider` is the function that says so. Nothing downstream of `when`
|
|
109
|
+
* moves — the same seed boundary, the same read-back, the same shape comparison
|
|
110
|
+
* — because both cycles already agree on what they return.
|
|
111
|
+
*
|
|
112
|
+
* ⚠ `run`'s error channel is written `E | CycleError` and must be: the chain adds
|
|
113
|
+
* that union itself, so a naive `Effect<Position, E, R>` double-counts it and
|
|
114
|
+
* fails to unify. `CycleError` exists to be written here.
|
|
115
|
+
*/
|
|
116
|
+
export declare const specificationForCycle: <Command, E, R, PR = never>(run: (command: Command) => Effect.Effect<Position | Unchanged, E | CycleError, DcbEventStore | Serializer | Uuid | R | PR>) => Specification<Command, E, R, PR>;
|
|
117
|
+
/**
|
|
118
|
+
* Begin a specification for `decider`. The returned `given(...)` starts the
|
|
119
|
+
* Given/When/Then chain; the terminal step yields an `Effect` requiring
|
|
120
|
+
* `DcbEventStore | Serializer | Uuid | R | RequirementOf<P>`.
|
|
121
|
+
*
|
|
122
|
+
* One line over the layered sibling above, and deliberately not a twin of it:
|
|
123
|
+
* a duplicated body would be two sets of tests and two things free to drift on
|
|
124
|
+
* the seed boundary, the read-back or the shape comparison.
|
|
125
|
+
*/
|
|
126
|
+
export declare const specificationFor: <P extends Record<string, SliceProjection>, Command, E, R, O extends DecisionOutput = Arr.NonEmptyReadonlyArray<DcbEvent>>(decider: Decider<P, Command, E, R, O>) => Specification<Command, E, R, RequirementOf<P>>;
|
|
127
|
+
/**
|
|
128
|
+
* `scenario(description, spec => spec.given(...).when(...).then(...))` — register
|
|
129
|
+
* an `@effect/vitest` `it.effect` case running `build` against a fresh in-memory
|
|
130
|
+
* `DcbEventStore` plus the default serialiser and a fresh deterministic uuid
|
|
131
|
+
* layer. The callback receives `specificationFor(decider)` so example suites
|
|
132
|
+
* read as a single Given/When/Then line per case.
|
|
133
|
+
*
|
|
134
|
+
* `scenario` provides exactly the store, serialiser, and uuid, so `build` must
|
|
135
|
+
* return an effect requiring only those three. For a plain decider (`R` and
|
|
136
|
+
* `RequirementOf<P>` both `never`) that is automatic; a decider carrying an
|
|
137
|
+
* encryption requirement provides its cipher layer inside `build` before
|
|
138
|
+
* returning.
|
|
139
|
+
*/
|
|
140
|
+
export declare const scenario: <P extends Record<string, SliceProjection>, Command, E, O extends DecisionOutput = Arr.NonEmptyReadonlyArray<DcbEvent>>(description: string, decider: Decider<P, Command, E, never, O>, build: (spec: Specification<Command, E, never, RequirementOf<P>>) => Effect.Effect<void, E | CycleError, DcbEventStore | Serializer | Uuid>) => void;
|
|
141
|
+
//# sourceMappingURL=specification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specification.d.ts","sourceRoot":"","sources":["../../src/specification.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,IAAI,EAEV,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,QAAQ,EACb,aAAa,EAGb,KAAK,QAAQ,EAGd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAA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qB,CAAC,QAAQ,CAAC,EAE9D,aAAa,MAAM,EACnB,SAAS,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EACzC,OAAO,CACL,IAAI,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,KACrD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,UAAU,EAAE,aAAa,GAAG,UAAU,GAAG,IAAI,CAAC,KAC1E,IAcF,CAAA"}
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
import { expect, it } from '@effect/vitest';
|
|
51
51
|
import { isUnchanged, runDecider, SerializerDefault, UuidTest } from '@kairos-es/codec';
|
|
52
52
|
import { DcbEventStore, DcbEventStoreInMemory, ORIGIN, query as Q } from '@kairos-es/core';
|
|
53
|
-
import { Cause,
|
|
53
|
+
import { Cause, Effect, Exit, Layer, Stream } from 'effect';
|
|
54
54
|
const shapeOf = event => ({
|
|
55
55
|
type: event.type,
|
|
56
56
|
tags: event.tags,
|
|
57
57
|
data: event.data
|
|
58
58
|
});
|
|
59
59
|
/** Collect a stream of sequenced events into a plain array. */
|
|
60
|
-
const collect = events => Stream.runCollect(events)
|
|
60
|
+
const collect = events => Stream.runCollect(events);
|
|
61
61
|
/**
|
|
62
62
|
* Seed the given past-event producers into the store: materialise each producer
|
|
63
63
|
* (encode -> serialise), then one append each (log order). Returns the position
|
|
@@ -143,7 +143,7 @@ export const specificationForCycle = run => ({
|
|
|
143
143
|
const exit = yield* runToExit;
|
|
144
144
|
expect(Exit.isFailure(exit)).toBe(true);
|
|
145
145
|
if (Exit.isFailure(exit)) {
|
|
146
|
-
const failure = Cause.
|
|
146
|
+
const failure = Cause.findErrorOption(exit.cause);
|
|
147
147
|
const error = failure._tag === 'Some' ? failure.value : undefined;
|
|
148
148
|
const actualTag = typeof error === 'object' && error !== null && '_tag' in error ? error._tag : undefined;
|
|
149
149
|
expect(actualTag).toBe(tag);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specification.js","names":["expect","it","isUnchanged","runDecider","SerializerDefault","UuidTest","DcbEventStore","DcbEventStoreInMemory","ORIGIN","query","Q","Cause","
|
|
1
|
+
{"version":3,"file":"specification.js","names":["expect","it","isUnchanged","runDecider","SerializerDefault","UuidTest","DcbEventStore","DcbEventStoreInMemory","ORIGIN","query","Q","Cause","Effect","Exit","Layer","Stream","shapeOf","event","type","tags","data","collect","events","runCollect","seed","producers","gen","store","last","producer","append","pipe","orDie","appendedAfter","after","read","all","specificationForCycle","run","given","pastEvents","when","command","runToExit","zip","exit","then","expected","isFailure","failCause","cause","seedBoundary","result","value","toBe","appended","expectedEvents","map","s","toEqual","thenError","tag","failure","findErrorOption","error","_tag","undefined","actualTag","thenUnchanged","specificationFor","decider","scenario","description","build","effect","provide","mergeAll","fresh"],"sources":["../../src/specification.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAASA,MAAM,EAAEC,EAAE,QAAQ,gBAAgB;AAW3C,SACEC,WAAW,EACXC,UAAU,EAEVC,iBAAiB,EAEjBC,QAAQ,QACH,kBAAkB;AACzB,SAGEC,aAAa,EACbC,qBAAqB,EACrBC,MAAM,EAENC,KAAK,IAAIC,CAAC,QAEL,iBAAiB;AACxB,SAA4BC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,QAAQ,QAAQ;AAmB9E,MAAMC,OAAO,GAAIC,KAAe,KAAkB;EAChDC,IAAI,EAAED,KAAK,CAACC,IAAI;EAChBC,IAAI,EAAEF,KAAK,CAACE,IAAI;EAChBC,IAAI,EAAEH,KAAK,CAACG;CACb,CAAC;AAEF;AACA,MAAMC,OAAO,GACXC,MAAqC,IACYP,MAAM,CAACQ,UAAU,CAACD,MAAM,CAAC;AAE5E;;;;;;;;;;;A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AACH,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kairos-es/testing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "Given/When/Then decision-model testing surface for kairos-es",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": {
|
|
@@ -11,19 +11,24 @@
|
|
|
11
11
|
"sideEffects": [],
|
|
12
12
|
"homepage": "https://github.com/neverbland/kairos-es",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@effect/vitest": "^0.
|
|
15
|
-
"effect": "^
|
|
16
|
-
"@kairos-es/
|
|
17
|
-
"@kairos-es/
|
|
14
|
+
"@effect/vitest": "^4.0.5",
|
|
15
|
+
"effect": "^4.0.5",
|
|
16
|
+
"@kairos-es/core": "^1.0.0-alpha.6",
|
|
17
|
+
"@kairos-es/codec": "^1.0.0-alpha.6"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/cjs/index.js",
|
|
20
20
|
"module": "./dist/esm/index.js",
|
|
21
|
-
"types": "./dist/dts/index.d.ts",
|
|
21
|
+
"types": "./dist/dts-cjs/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/dts-esm/index.d.ts",
|
|
26
|
+
"default": "./dist/esm/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/dts-cjs/index.d.ts",
|
|
30
|
+
"default": "./dist/cjs/index.js"
|
|
31
|
+
}
|
|
27
32
|
},
|
|
28
33
|
"./package.json": "./package.json"
|
|
29
34
|
},
|
package/src/specification.ts
CHANGED
|
@@ -76,15 +76,7 @@ import {
|
|
|
76
76
|
query as Q,
|
|
77
77
|
type SequencedEvent,
|
|
78
78
|
} from '@kairos-es/core'
|
|
79
|
-
import {
|
|
80
|
-
type Array as Arr,
|
|
81
|
-
Cause,
|
|
82
|
-
Chunk,
|
|
83
|
-
Effect,
|
|
84
|
-
Exit,
|
|
85
|
-
Layer,
|
|
86
|
-
Stream,
|
|
87
|
-
} from 'effect'
|
|
79
|
+
import { type Array as Arr, Cause, Effect, Exit, Layer, Stream } from 'effect'
|
|
88
80
|
|
|
89
81
|
/** An effectful producer of a wire event (the `toEvent` result an app authors). */
|
|
90
82
|
export type EventProducer<R> = Effect.Effect<
|
|
@@ -112,8 +104,7 @@ const shapeOf = (event: DcbEvent): EventShape => ({
|
|
|
112
104
|
/** Collect a stream of sequenced events into a plain array. */
|
|
113
105
|
const collect = (
|
|
114
106
|
events: Stream.Stream<SequencedEvent>,
|
|
115
|
-
): Effect.Effect<ReadonlyArray<SequencedEvent>> =>
|
|
116
|
-
Stream.runCollect(events).pipe(Effect.map(Chunk.toReadonlyArray))
|
|
107
|
+
): Effect.Effect<ReadonlyArray<SequencedEvent>> => Stream.runCollect(events)
|
|
117
108
|
|
|
118
109
|
/**
|
|
119
110
|
* Seed the given past-event producers into the store: materialise each producer
|
|
@@ -335,7 +326,7 @@ export const specificationForCycle = <Command, E, R, PR = never>(
|
|
|
335
326
|
const exit = yield* runToExit
|
|
336
327
|
expect(Exit.isFailure(exit)).toBe(true)
|
|
337
328
|
if (Exit.isFailure(exit)) {
|
|
338
|
-
const failure = Cause.
|
|
329
|
+
const failure = Cause.findErrorOption(exit.cause)
|
|
339
330
|
const error = failure._tag === 'Some' ? failure.value : undefined
|
|
340
331
|
const actualTag =
|
|
341
332
|
typeof error === 'object' && error !== null && '_tag' in error
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"specification.d.ts","sourceRoot":"","sources":["../../src/specification.ts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,SAAS,E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