@reventlessdev/reventless-gwt 1.0.0-alpha.76 → 1.0.0-alpha.78
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/CHANGELOG.md +16 -0
- package/package.json +7 -7
- package/src/Behavior_GWT.res +125 -159
- package/src/Behavior_GWT.res.mjs +156 -59
- package/src/BuildClassifier.res +15 -5
- package/src/BuildClassifier.res.mjs +3 -3
- package/src/Cli.res +157 -29
- package/src/Cli.res.mjs +138 -24
- package/src/Collector.res +2 -2
- package/src/Collector.res.mjs +2 -2
- package/src/ComponentMeta.res +16 -43
- package/src/ComponentMeta.res.mjs +12 -41
- package/src/Discovery.res +19 -19
- package/src/Discovery.res.mjs +5 -9
- package/src/DomainGraph.res +0 -0
- package/src/DomainGraph.res.mjs +0 -0
- package/src/FormatterHuman.res +14 -43
- package/src/FormatterHuman.res.mjs +21 -28
- package/src/FormatterJson.res +12 -5
- package/src/FormatterJson.res.mjs +8 -6
- package/src/FormatterTap.res +13 -52
- package/src/FormatterTap.res.mjs +25 -43
- package/src/FormatterVsCode.res +4 -19
- package/src/FormatterVsCode.res.mjs +4 -23
- package/src/LocalHost.res +11 -27
- package/src/LocalHost.res.mjs +6 -34
- package/src/MismatchRender.res +72 -0
- package/src/MismatchRender.res.mjs +127 -0
- package/src/Outcome.res +0 -64
- package/src/Outcome.res.mjs +0 -47
- package/src/PlatformScan.res +14 -10
- package/src/PlatformScan.res.mjs +14 -13
- package/tests/BuildClassifierTest.res +39 -0
- package/tests/BuildClassifierTest.res.mjs +44 -0
- package/tests/CliWatchScopeTest.res +62 -0
- package/tests/CliWatchScopeTest.res.mjs +95 -0
- package/tests/ComponentMetaTest.res +15 -0
- package/tests/ComponentMetaTest.res.mjs +14 -0
- package/tests/DomainGraphTest.res +2 -2
- package/tests/FlowAggregateGwtTest.res +2 -0
- package/tests/FlowAggregateGwtTest.res.mjs +4 -0
- package/tests/FormatterGoldenTest.res +125 -0
- package/tests/FormatterGoldenTest.res.mjs +162 -0
- package/tests/MappingGwtTest.res +2 -0
- package/tests/MappingGwtTest.res.mjs +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 1.0.0-alpha.78 (2026-07-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @reventlessdev/reventless-gwt
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 1.0.0-alpha.77 (2026-07-03)
|
|
15
|
+
|
|
16
|
+
### Performance Improvements
|
|
17
|
+
|
|
18
|
+
* **gwt:** affected-set watch re-runs + parent-owned discovery (plan B1) ([e7f4e6b](https://github.com/ReventlessDev/reventless-core/commit/e7f4e6bff8c28fdbcf1b15503005ed2ac613fa06))
|
|
19
|
+
* **gwt:** graph-reload dedup, build-classifier fixes, drop quadratic walks (plan B3) ([aeda1b4](https://github.com/ReventlessDev/reventless-core/commit/aeda1b47aec36373aee788def449959a290042f3))
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# 1.0.0-alpha.76 (2026-07-02)
|
|
7
23
|
|
|
8
24
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-gwt",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.78",
|
|
4
4
|
"description": "Given-When-Then DSLs and CLI runner for Reventless slice testing",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"chokidar": "^3.6.0",
|
|
21
21
|
"picocolors": "^1.1.1",
|
|
22
22
|
"sury": "11.0.0-alpha.4",
|
|
23
|
-
"@reventlessdev/rescript-effect": "0.1.0-alpha.24",
|
|
24
23
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.5",
|
|
25
|
-
"@reventlessdev/
|
|
26
|
-
"@reventlessdev/reventless-core": "3.0.0-alpha.
|
|
27
|
-
"@reventlessdev/reventless-
|
|
28
|
-
"@reventlessdev/reventless-
|
|
24
|
+
"@reventlessdev/rescript-effect": "0.1.0-alpha.24",
|
|
25
|
+
"@reventlessdev/reventless-core": "3.0.0-alpha.138",
|
|
26
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.84",
|
|
27
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.64",
|
|
28
|
+
"@reventlessdev/reventless-vscode-protocol": "1.0.0-alpha.11"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"rescript": "^12.3.0",
|
|
32
32
|
"sury-ppx": "11.0.0-alpha.2",
|
|
33
|
-
"@reventlessdev/reventless-ppx": "1.0.0-alpha.
|
|
33
|
+
"@reventlessdev/reventless-ppx": "1.0.0-alpha.50"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"rescript": "^12.3.0"
|
package/src/Behavior_GWT.res
CHANGED
|
@@ -117,6 +117,111 @@ let encodeAppendCondition = (c: Reventless.DcbTag.appendCondition): JSON.t => {
|
|
|
117
117
|
JSON.Encode.object(d)
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Shared assertion core for both Behavior GWT flavours.
|
|
122
|
+
//
|
|
123
|
+
// `Make` (slice/DCB) and `MakeFromAggregate` encode produced events / errors
|
|
124
|
+
// identically and compare them against the expectation the same way — only the
|
|
125
|
+
// DCB append-condition footgun that `Make` layers on top, and the `thenCompare*`
|
|
126
|
+
// custom-equality arms the aggregate flavour adds, differ. Factoring the
|
|
127
|
+
// comparison core out (mirroring `Delegate_GWT`'s `Make`) keeps the two from
|
|
128
|
+
// silently drifting. The `errors` ref is owned here and set by each outer
|
|
129
|
+
// functor's `exec`.
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
module type CoreSpec = {
|
|
132
|
+
@schema
|
|
133
|
+
type event
|
|
134
|
+
@schema
|
|
135
|
+
type error
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module AssertionCore = (Spec: CoreSpec) => {
|
|
139
|
+
let errors: ref<array<Spec.error>> = ref([])
|
|
140
|
+
|
|
141
|
+
let encEvent = (e: Spec.event) => e->Message.encode(Spec.eventSchema)
|
|
142
|
+
let encEvents = evs => evs->Array.map(encEvent)
|
|
143
|
+
let encError = (err: Spec.error) => err->Message.encode(Spec.errorSchema)
|
|
144
|
+
|
|
145
|
+
let unexpectedError = (events: array<Spec.event>): Outcome.outcome => {
|
|
146
|
+
let actual = errors.contents->Array.get(0)->Option.map(encError)
|
|
147
|
+
Outcome.fail(
|
|
148
|
+
ErrorMismatch({
|
|
149
|
+
expected: JSON.Encode.null,
|
|
150
|
+
actual,
|
|
151
|
+
actualEvents: events->encEvents,
|
|
152
|
+
}),
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let compareEvents = (events, expectedEvents) =>
|
|
157
|
+
if errors.contents->Array.length > 0 {
|
|
158
|
+
unexpectedError(events)
|
|
159
|
+
} else if events == expectedEvents {
|
|
160
|
+
Outcome.pass
|
|
161
|
+
} else {
|
|
162
|
+
Outcome.fail(
|
|
163
|
+
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let compareEventsWith = (events, expectedEvents, cmp) =>
|
|
168
|
+
if errors.contents->Array.length > 0 {
|
|
169
|
+
unexpectedError(events)
|
|
170
|
+
} else if (
|
|
171
|
+
events->Array.length == expectedEvents->Array.length &&
|
|
172
|
+
Array.zip(events, expectedEvents)->Array.every(((e1, e2)) => cmp(e1, e2))
|
|
173
|
+
) {
|
|
174
|
+
Outcome.pass
|
|
175
|
+
} else {
|
|
176
|
+
Outcome.fail(
|
|
177
|
+
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let compareNoEvent = events =>
|
|
182
|
+
if errors.contents->Array.length > 0 {
|
|
183
|
+
unexpectedError(events)
|
|
184
|
+
} else if events->Array.length == 0 {
|
|
185
|
+
Outcome.pass
|
|
186
|
+
} else {
|
|
187
|
+
Outcome.fail(NoEventExpected({actual: events->encEvents}))
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let matchesError = (
|
|
191
|
+
events: array<Spec.event>,
|
|
192
|
+
expectedEvents: array<Spec.event>,
|
|
193
|
+
expectedError: Spec.error,
|
|
194
|
+
): Outcome.outcome => {
|
|
195
|
+
let expectedErrorJson = encError(expectedError)
|
|
196
|
+
switch errors.contents->Array.get(0) {
|
|
197
|
+
| None =>
|
|
198
|
+
Outcome.fail(
|
|
199
|
+
ErrorMismatch({
|
|
200
|
+
expected: expectedErrorJson,
|
|
201
|
+
actual: None,
|
|
202
|
+
actualEvents: events->encEvents,
|
|
203
|
+
}),
|
|
204
|
+
)
|
|
205
|
+
| Some(actual) if actual != expectedError =>
|
|
206
|
+
Outcome.fail(
|
|
207
|
+
ErrorMismatch({
|
|
208
|
+
expected: expectedErrorJson,
|
|
209
|
+
actual: Some(encError(actual)),
|
|
210
|
+
actualEvents: events->encEvents,
|
|
211
|
+
}),
|
|
212
|
+
)
|
|
213
|
+
| Some(_) =>
|
|
214
|
+
if events == expectedEvents {
|
|
215
|
+
Outcome.pass
|
|
216
|
+
} else {
|
|
217
|
+
Outcome.fail(
|
|
218
|
+
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
120
225
|
module Make = (
|
|
121
226
|
Spec: BehaviorSpec,
|
|
122
227
|
Behavior: Behavior with module Spec := Spec,
|
|
@@ -132,7 +237,8 @@ module Make = (
|
|
|
132
237
|
let currentState = consumed =>
|
|
133
238
|
consumed->Array.reduce(Behavior.initialState, Behavior.evolve)
|
|
134
239
|
|
|
135
|
-
|
|
240
|
+
module Core = AssertionCore(Spec)
|
|
241
|
+
let errors = Core.errors
|
|
136
242
|
|
|
137
243
|
// DCB append-condition derived inside [whenCmd]; [None] until first call.
|
|
138
244
|
let derivedCondition: ref<option<Reventless.DcbTag.appendCondition>> = ref(None)
|
|
@@ -280,37 +386,15 @@ module Make = (
|
|
|
280
386
|
let givenEvents = consumed => consumed
|
|
281
387
|
let whenCmd = (history, cmd) => history->exec(cmd)
|
|
282
388
|
|
|
283
|
-
let encEvent = (e: Spec.event) => e->Message.encode(Spec.eventSchema)
|
|
284
|
-
let encEvents = evs => evs->Array.map(encEvent)
|
|
285
|
-
let encError = (err: Spec.error) => err->Message.encode(Spec.errorSchema)
|
|
286
|
-
|
|
287
389
|
let checkAppendCondition = (): option<Outcome.outcome> =>
|
|
288
390
|
appendConditionFailure.contents->Option.map(m => Outcome.fail(m))
|
|
289
391
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
Outcome.fail(
|
|
293
|
-
ErrorMismatch({
|
|
294
|
-
expected: JSON.Encode.null,
|
|
295
|
-
actual,
|
|
296
|
-
actualEvents: events->encEvents,
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
}
|
|
300
|
-
|
|
392
|
+
// The append-condition footgun is surfaced before the shared comparison core
|
|
393
|
+
// runs; `thenAppends*` below bypass it deliberately.
|
|
301
394
|
let thenEvents = (events, expectedEvents) =>
|
|
302
395
|
switch checkAppendCondition() {
|
|
303
396
|
| Some(o) => o
|
|
304
|
-
| None =>
|
|
305
|
-
if errors.contents->Array.length > 0 {
|
|
306
|
-
unexpectedError(events)
|
|
307
|
-
} else if events == expectedEvents {
|
|
308
|
-
Outcome.pass
|
|
309
|
-
} else {
|
|
310
|
-
Outcome.fail(
|
|
311
|
-
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
312
|
-
)
|
|
313
|
-
}
|
|
397
|
+
| None => Core.compareEvents(events, expectedEvents)
|
|
314
398
|
}
|
|
315
399
|
|
|
316
400
|
let thenEvent = (events, expectedEvent) => thenEvents(events, [expectedEvent])
|
|
@@ -318,66 +402,25 @@ module Make = (
|
|
|
318
402
|
let thenNoEvent = events =>
|
|
319
403
|
switch checkAppendCondition() {
|
|
320
404
|
| Some(o) => o
|
|
321
|
-
| None =>
|
|
322
|
-
if errors.contents->Array.length > 0 {
|
|
323
|
-
unexpectedError(events)
|
|
324
|
-
} else if events->Array.length == 0 {
|
|
325
|
-
Outcome.pass
|
|
326
|
-
} else {
|
|
327
|
-
Outcome.fail(NoEventExpected({actual: events->encEvents}))
|
|
328
|
-
}
|
|
405
|
+
| None => Core.compareNoEvent(events)
|
|
329
406
|
}
|
|
330
407
|
|
|
331
|
-
let matchesError = (
|
|
332
|
-
events: array<Spec.event>,
|
|
333
|
-
expectedEvents: array<Spec.event>,
|
|
334
|
-
expectedError: Spec.error,
|
|
335
|
-
): Outcome.outcome => {
|
|
336
|
-
let expectedErrorJson = encError(expectedError)
|
|
337
|
-
switch errors.contents->Array.get(0) {
|
|
338
|
-
| None =>
|
|
339
|
-
Outcome.fail(
|
|
340
|
-
ErrorMismatch({
|
|
341
|
-
expected: expectedErrorJson,
|
|
342
|
-
actual: None,
|
|
343
|
-
actualEvents: events->encEvents,
|
|
344
|
-
}),
|
|
345
|
-
)
|
|
346
|
-
| Some(actual) if actual != expectedError =>
|
|
347
|
-
Outcome.fail(
|
|
348
|
-
ErrorMismatch({
|
|
349
|
-
expected: expectedErrorJson,
|
|
350
|
-
actual: Some(encError(actual)),
|
|
351
|
-
actualEvents: events->encEvents,
|
|
352
|
-
}),
|
|
353
|
-
)
|
|
354
|
-
| Some(_) =>
|
|
355
|
-
if events == expectedEvents {
|
|
356
|
-
Outcome.pass
|
|
357
|
-
} else {
|
|
358
|
-
Outcome.fail(
|
|
359
|
-
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
360
|
-
)
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
408
|
let thenError = (events, expectedError) =>
|
|
366
409
|
switch checkAppendCondition() {
|
|
367
410
|
| Some(o) => o
|
|
368
|
-
| None => matchesError(events, [], expectedError)
|
|
411
|
+
| None => Core.matchesError(events, [], expectedError)
|
|
369
412
|
}
|
|
370
413
|
|
|
371
414
|
let thenEventWithError = (events, expectedEvent, expectedError) =>
|
|
372
415
|
switch checkAppendCondition() {
|
|
373
416
|
| Some(o) => o
|
|
374
|
-
| None => matchesError(events, [expectedEvent], expectedError)
|
|
417
|
+
| None => Core.matchesError(events, [expectedEvent], expectedError)
|
|
375
418
|
}
|
|
376
419
|
|
|
377
420
|
let thenEventsWithError = (events, expectedEvents, expectedError) =>
|
|
378
421
|
switch checkAppendCondition() {
|
|
379
422
|
| Some(o) => o
|
|
380
|
-
| None => matchesError(events, expectedEvents, expectedError)
|
|
423
|
+
| None => Core.matchesError(events, expectedEvents, expectedError)
|
|
381
424
|
}
|
|
382
425
|
|
|
383
426
|
let thenAppendsConditionedOn = (_events, expectedQuery: Reventless.DcbTag.query) =>
|
|
@@ -489,7 +532,8 @@ module MakeFromAggregate = (
|
|
|
489
532
|
let currentState = events =>
|
|
490
533
|
events->Array.reduce(Behavior.initialState, Behavior.evolve)
|
|
491
534
|
|
|
492
|
-
|
|
535
|
+
module Core = AssertionCore(Spec)
|
|
536
|
+
let errors = Core.errors
|
|
493
537
|
|
|
494
538
|
let exec = (history, command): array<Spec.event> => {
|
|
495
539
|
errors := []
|
|
@@ -505,99 +549,21 @@ module MakeFromAggregate = (
|
|
|
505
549
|
let givenEvents = events => events
|
|
506
550
|
let whenCmd = (history, cmd) => history->exec(cmd)
|
|
507
551
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
let
|
|
513
|
-
let actual = errors.contents->Array.get(0)->Option.map(encError)
|
|
514
|
-
Outcome.fail(
|
|
515
|
-
ErrorMismatch({
|
|
516
|
-
expected: JSON.Encode.null,
|
|
517
|
-
actual,
|
|
518
|
-
actualEvents: events->encEvents,
|
|
519
|
-
}),
|
|
520
|
-
)
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
let thenEvents = (events, expectedEvents) =>
|
|
524
|
-
if errors.contents->Array.length > 0 {
|
|
525
|
-
unexpectedError(events)
|
|
526
|
-
} else if events == expectedEvents {
|
|
527
|
-
Outcome.pass
|
|
528
|
-
} else {
|
|
529
|
-
Outcome.fail(
|
|
530
|
-
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
531
|
-
)
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
let thenCompareEvents = (events, expectedEvents, cmp) =>
|
|
535
|
-
if errors.contents->Array.length > 0 {
|
|
536
|
-
unexpectedError(events)
|
|
537
|
-
} else if (
|
|
538
|
-
events->Array.length == expectedEvents->Array.length &&
|
|
539
|
-
Array.zip(events, expectedEvents)->Array.every(((e1, e2)) => cmp(e1, e2))
|
|
540
|
-
) {
|
|
541
|
-
Outcome.pass
|
|
542
|
-
} else {
|
|
543
|
-
Outcome.fail(
|
|
544
|
-
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
545
|
-
)
|
|
546
|
-
}
|
|
547
|
-
|
|
552
|
+
// The aggregate flavour has no append-condition footgun, so the shared core's
|
|
553
|
+
// comparisons are exposed directly; only `thenCompare*` (custom equality) is
|
|
554
|
+
// specific to this surface.
|
|
555
|
+
let thenEvents = Core.compareEvents
|
|
556
|
+
let thenCompareEvents = Core.compareEventsWith
|
|
548
557
|
let thenEvent = (events, expectedEvent) => thenEvents(events, [expectedEvent])
|
|
549
|
-
|
|
550
558
|
let thenCompareEvent = (events, expectedEvent, cmp) =>
|
|
551
559
|
thenCompareEvents(events, [expectedEvent], cmp)
|
|
560
|
+
let thenNoEvent = Core.compareNoEvent
|
|
552
561
|
|
|
553
|
-
let
|
|
554
|
-
if errors.contents->Array.length > 0 {
|
|
555
|
-
unexpectedError(events)
|
|
556
|
-
} else if events->Array.length == 0 {
|
|
557
|
-
Outcome.pass
|
|
558
|
-
} else {
|
|
559
|
-
Outcome.fail(NoEventExpected({actual: events->encEvents}))
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
let matchesError = (
|
|
563
|
-
events: array<Spec.event>,
|
|
564
|
-
expectedEvents: array<Spec.event>,
|
|
565
|
-
expectedError: Spec.error,
|
|
566
|
-
): Outcome.outcome => {
|
|
567
|
-
let expectedErrorJson = encError(expectedError)
|
|
568
|
-
switch errors.contents->Array.get(0) {
|
|
569
|
-
| None =>
|
|
570
|
-
Outcome.fail(
|
|
571
|
-
ErrorMismatch({
|
|
572
|
-
expected: expectedErrorJson,
|
|
573
|
-
actual: None,
|
|
574
|
-
actualEvents: events->encEvents,
|
|
575
|
-
}),
|
|
576
|
-
)
|
|
577
|
-
| Some(actual) if actual != expectedError =>
|
|
578
|
-
Outcome.fail(
|
|
579
|
-
ErrorMismatch({
|
|
580
|
-
expected: expectedErrorJson,
|
|
581
|
-
actual: Some(encError(actual)),
|
|
582
|
-
actualEvents: events->encEvents,
|
|
583
|
-
}),
|
|
584
|
-
)
|
|
585
|
-
| Some(_) =>
|
|
586
|
-
if events == expectedEvents {
|
|
587
|
-
Outcome.pass
|
|
588
|
-
} else {
|
|
589
|
-
Outcome.fail(
|
|
590
|
-
EventsMismatch({expected: expectedEvents->encEvents, actual: events->encEvents}),
|
|
591
|
-
)
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
let thenError = (events, expectedError) => matchesError(events, [], expectedError)
|
|
562
|
+
let thenError = (events, expectedError) => Core.matchesError(events, [], expectedError)
|
|
597
563
|
|
|
598
564
|
let thenEventWithError = (events, expectedEvent, expectedError) =>
|
|
599
|
-
matchesError(events, [expectedEvent], expectedError)
|
|
565
|
+
Core.matchesError(events, [expectedEvent], expectedError)
|
|
600
566
|
|
|
601
567
|
let thenEventsWithError = (events, expectedEvents, expectedError) =>
|
|
602
|
-
matchesError(events, expectedEvents, expectedError)
|
|
568
|
+
Core.matchesError(events, expectedEvents, expectedError)
|
|
603
569
|
}
|
package/src/Behavior_GWT.res.mjs
CHANGED
|
@@ -47,6 +47,102 @@ function encodeAppendCondition(c) {
|
|
|
47
47
|
return d;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function AssertionCore(Spec) {
|
|
51
|
+
let errors = {
|
|
52
|
+
contents: []
|
|
53
|
+
};
|
|
54
|
+
let encEvent = e => Message$ReventlessCore.encode(e, Spec.eventSchema);
|
|
55
|
+
let encEvents = evs => evs.map(encEvent);
|
|
56
|
+
let encError = err => Message$ReventlessCore.encode(err, Spec.errorSchema);
|
|
57
|
+
let unexpectedError = events => {
|
|
58
|
+
let actual = Stdlib_Option.map(errors.contents[0], encError);
|
|
59
|
+
return Outcome$ReventlessGwt.fail({
|
|
60
|
+
TAG: "ErrorMismatch",
|
|
61
|
+
expected: null,
|
|
62
|
+
actual: actual,
|
|
63
|
+
actualEvents: events.map(encEvent)
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
let compareEvents = (events, expectedEvents) => {
|
|
67
|
+
if (errors.contents.length !== 0) {
|
|
68
|
+
return unexpectedError(events);
|
|
69
|
+
} else if (Primitive_object.equal(events, expectedEvents)) {
|
|
70
|
+
return Outcome$ReventlessGwt.pass;
|
|
71
|
+
} else {
|
|
72
|
+
return Outcome$ReventlessGwt.fail({
|
|
73
|
+
TAG: "EventsMismatch",
|
|
74
|
+
expected: expectedEvents.map(encEvent),
|
|
75
|
+
actual: events.map(encEvent)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
let compareEventsWith = (events, expectedEvents, cmp) => {
|
|
80
|
+
if (errors.contents.length !== 0) {
|
|
81
|
+
return unexpectedError(events);
|
|
82
|
+
} else if (events.length === expectedEvents.length && Stdlib_Array.zip(events, expectedEvents).every(param => cmp(param[0], param[1]))) {
|
|
83
|
+
return Outcome$ReventlessGwt.pass;
|
|
84
|
+
} else {
|
|
85
|
+
return Outcome$ReventlessGwt.fail({
|
|
86
|
+
TAG: "EventsMismatch",
|
|
87
|
+
expected: expectedEvents.map(encEvent),
|
|
88
|
+
actual: events.map(encEvent)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
let compareNoEvent = events => {
|
|
93
|
+
if (errors.contents.length !== 0) {
|
|
94
|
+
return unexpectedError(events);
|
|
95
|
+
} else if (events.length === 0) {
|
|
96
|
+
return Outcome$ReventlessGwt.pass;
|
|
97
|
+
} else {
|
|
98
|
+
return Outcome$ReventlessGwt.fail({
|
|
99
|
+
TAG: "NoEventExpected",
|
|
100
|
+
actual: events.map(encEvent)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
let matchesError = (events, expectedEvents, expectedError) => {
|
|
105
|
+
let expectedErrorJson = Message$ReventlessCore.encode(expectedError, Spec.errorSchema);
|
|
106
|
+
let actual = errors.contents[0];
|
|
107
|
+
if (actual === undefined) {
|
|
108
|
+
return Outcome$ReventlessGwt.fail({
|
|
109
|
+
TAG: "ErrorMismatch",
|
|
110
|
+
expected: expectedErrorJson,
|
|
111
|
+
actual: undefined,
|
|
112
|
+
actualEvents: events.map(encEvent)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
let actual$1 = Primitive_option.valFromOption(actual);
|
|
116
|
+
if (Primitive_object.notequal(actual$1, expectedError)) {
|
|
117
|
+
return Outcome$ReventlessGwt.fail({
|
|
118
|
+
TAG: "ErrorMismatch",
|
|
119
|
+
expected: expectedErrorJson,
|
|
120
|
+
actual: Message$ReventlessCore.encode(actual$1, Spec.errorSchema),
|
|
121
|
+
actualEvents: events.map(encEvent)
|
|
122
|
+
});
|
|
123
|
+
} else if (Primitive_object.equal(events, expectedEvents)) {
|
|
124
|
+
return Outcome$ReventlessGwt.pass;
|
|
125
|
+
} else {
|
|
126
|
+
return Outcome$ReventlessGwt.fail({
|
|
127
|
+
TAG: "EventsMismatch",
|
|
128
|
+
expected: expectedEvents.map(encEvent),
|
|
129
|
+
actual: events.map(encEvent)
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
errors: errors,
|
|
135
|
+
encEvent: encEvent,
|
|
136
|
+
encEvents: encEvents,
|
|
137
|
+
encError: encError,
|
|
138
|
+
unexpectedError: unexpectedError,
|
|
139
|
+
compareEvents: compareEvents,
|
|
140
|
+
compareEventsWith: compareEventsWith,
|
|
141
|
+
compareNoEvent: compareNoEvent,
|
|
142
|
+
matchesError: matchesError
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
50
146
|
function Make(Spec) {
|
|
51
147
|
return Behavior => {
|
|
52
148
|
S.enableJson();
|
|
@@ -54,6 +150,46 @@ function Make(Spec) {
|
|
|
54
150
|
let errors = {
|
|
55
151
|
contents: []
|
|
56
152
|
};
|
|
153
|
+
let encEvent = e => Message$ReventlessCore.encode(e, Spec.eventSchema);
|
|
154
|
+
let encError = err => Message$ReventlessCore.encode(err, Spec.errorSchema);
|
|
155
|
+
let unexpectedError = events => {
|
|
156
|
+
let actual = Stdlib_Option.map(errors.contents[0], encError);
|
|
157
|
+
return Outcome$ReventlessGwt.fail({
|
|
158
|
+
TAG: "ErrorMismatch",
|
|
159
|
+
expected: null,
|
|
160
|
+
actual: actual,
|
|
161
|
+
actualEvents: events.map(encEvent)
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
let matchesError = (events, expectedEvents, expectedError) => {
|
|
165
|
+
let expectedErrorJson = Message$ReventlessCore.encode(expectedError, Spec.errorSchema);
|
|
166
|
+
let actual = errors.contents[0];
|
|
167
|
+
if (actual === undefined) {
|
|
168
|
+
return Outcome$ReventlessGwt.fail({
|
|
169
|
+
TAG: "ErrorMismatch",
|
|
170
|
+
expected: expectedErrorJson,
|
|
171
|
+
actual: undefined,
|
|
172
|
+
actualEvents: events.map(encEvent)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
let actual$1 = Primitive_option.valFromOption(actual);
|
|
176
|
+
if (Primitive_object.notequal(actual$1, expectedError)) {
|
|
177
|
+
return Outcome$ReventlessGwt.fail({
|
|
178
|
+
TAG: "ErrorMismatch",
|
|
179
|
+
expected: expectedErrorJson,
|
|
180
|
+
actual: Message$ReventlessCore.encode(actual$1, Spec.errorSchema),
|
|
181
|
+
actualEvents: events.map(encEvent)
|
|
182
|
+
});
|
|
183
|
+
} else if (Primitive_object.equal(events, expectedEvents)) {
|
|
184
|
+
return Outcome$ReventlessGwt.pass;
|
|
185
|
+
} else {
|
|
186
|
+
return Outcome$ReventlessGwt.fail({
|
|
187
|
+
TAG: "EventsMismatch",
|
|
188
|
+
expected: expectedEvents.map(encEvent),
|
|
189
|
+
actual: events.map(encEvent)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
57
193
|
let derivedCondition = {
|
|
58
194
|
contents: undefined
|
|
59
195
|
};
|
|
@@ -138,18 +274,7 @@ function Make(Spec) {
|
|
|
138
274
|
errors.contents = [events._0];
|
|
139
275
|
return [];
|
|
140
276
|
};
|
|
141
|
-
let encEvent = e => Message$ReventlessCore.encode(e, Spec.eventSchema);
|
|
142
|
-
let encError = err => Message$ReventlessCore.encode(err, Spec.errorSchema);
|
|
143
277
|
let checkAppendCondition = () => Stdlib_Option.map(appendConditionFailure.contents, Outcome$ReventlessGwt.fail);
|
|
144
|
-
let unexpectedError = events => {
|
|
145
|
-
let actual = Stdlib_Option.map(errors.contents[0], encError);
|
|
146
|
-
return Outcome$ReventlessGwt.fail({
|
|
147
|
-
TAG: "ErrorMismatch",
|
|
148
|
-
expected: null,
|
|
149
|
-
actual: actual,
|
|
150
|
-
actualEvents: events.map(encEvent)
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
278
|
let thenEvents = (events, expectedEvents) => {
|
|
154
279
|
let o = checkAppendCondition();
|
|
155
280
|
if (o !== undefined) {
|
|
@@ -182,35 +307,6 @@ function Make(Spec) {
|
|
|
182
307
|
});
|
|
183
308
|
}
|
|
184
309
|
};
|
|
185
|
-
let matchesError = (events, expectedEvents, expectedError) => {
|
|
186
|
-
let expectedErrorJson = Message$ReventlessCore.encode(expectedError, Spec.errorSchema);
|
|
187
|
-
let actual = errors.contents[0];
|
|
188
|
-
if (actual === undefined) {
|
|
189
|
-
return Outcome$ReventlessGwt.fail({
|
|
190
|
-
TAG: "ErrorMismatch",
|
|
191
|
-
expected: expectedErrorJson,
|
|
192
|
-
actual: undefined,
|
|
193
|
-
actualEvents: events.map(encEvent)
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
let actual$1 = Primitive_option.valFromOption(actual);
|
|
197
|
-
if (Primitive_object.notequal(actual$1, expectedError)) {
|
|
198
|
-
return Outcome$ReventlessGwt.fail({
|
|
199
|
-
TAG: "ErrorMismatch",
|
|
200
|
-
expected: expectedErrorJson,
|
|
201
|
-
actual: Message$ReventlessCore.encode(actual$1, Spec.errorSchema),
|
|
202
|
-
actualEvents: events.map(encEvent)
|
|
203
|
-
});
|
|
204
|
-
} else if (Primitive_object.equal(events, expectedEvents)) {
|
|
205
|
-
return Outcome$ReventlessGwt.pass;
|
|
206
|
-
} else {
|
|
207
|
-
return Outcome$ReventlessGwt.fail({
|
|
208
|
-
TAG: "EventsMismatch",
|
|
209
|
-
expected: expectedEvents.map(encEvent),
|
|
210
|
-
actual: events.map(encEvent)
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
310
|
let thenError = (events, expectedError) => {
|
|
215
311
|
let o = checkAppendCondition();
|
|
216
312
|
if (o !== undefined) {
|
|
@@ -303,17 +399,6 @@ function MakeFromAggregate(Spec) {
|
|
|
303
399
|
let errors = {
|
|
304
400
|
contents: []
|
|
305
401
|
};
|
|
306
|
-
let givenEvents = events => events;
|
|
307
|
-
let whenCmd = (history, cmd) => {
|
|
308
|
-
errors.contents = [];
|
|
309
|
-
let state = Stdlib_Array.reduce(history, Behavior.initialState, Behavior.evolve);
|
|
310
|
-
let events = Behavior.decide(state, cmd);
|
|
311
|
-
if (events.TAG === "Ok") {
|
|
312
|
-
return events._0;
|
|
313
|
-
}
|
|
314
|
-
errors.contents = [events._0];
|
|
315
|
-
return [];
|
|
316
|
-
};
|
|
317
402
|
let encEvent = e => Message$ReventlessCore.encode(e, Spec.eventSchema);
|
|
318
403
|
let encError = err => Message$ReventlessCore.encode(err, Spec.errorSchema);
|
|
319
404
|
let unexpectedError = events => {
|
|
@@ -325,7 +410,7 @@ function MakeFromAggregate(Spec) {
|
|
|
325
410
|
actualEvents: events.map(encEvent)
|
|
326
411
|
});
|
|
327
412
|
};
|
|
328
|
-
let
|
|
413
|
+
let compareEvents = (events, expectedEvents) => {
|
|
329
414
|
if (errors.contents.length !== 0) {
|
|
330
415
|
return unexpectedError(events);
|
|
331
416
|
} else if (Primitive_object.equal(events, expectedEvents)) {
|
|
@@ -338,7 +423,7 @@ function MakeFromAggregate(Spec) {
|
|
|
338
423
|
});
|
|
339
424
|
}
|
|
340
425
|
};
|
|
341
|
-
let
|
|
426
|
+
let compareEventsWith = (events, expectedEvents, cmp) => {
|
|
342
427
|
if (errors.contents.length !== 0) {
|
|
343
428
|
return unexpectedError(events);
|
|
344
429
|
} else if (events.length === expectedEvents.length && Stdlib_Array.zip(events, expectedEvents).every(param => cmp(param[0], param[1]))) {
|
|
@@ -351,9 +436,7 @@ function MakeFromAggregate(Spec) {
|
|
|
351
436
|
});
|
|
352
437
|
}
|
|
353
438
|
};
|
|
354
|
-
let
|
|
355
|
-
let thenCompareEvent = (events, expectedEvent, cmp) => thenCompareEvents(events, [expectedEvent], cmp);
|
|
356
|
-
let thenNoEvent = events => {
|
|
439
|
+
let compareNoEvent = events => {
|
|
357
440
|
if (errors.contents.length !== 0) {
|
|
358
441
|
return unexpectedError(events);
|
|
359
442
|
} else if (events.length === 0) {
|
|
@@ -394,6 +477,19 @@ function MakeFromAggregate(Spec) {
|
|
|
394
477
|
});
|
|
395
478
|
}
|
|
396
479
|
};
|
|
480
|
+
let givenEvents = events => events;
|
|
481
|
+
let whenCmd = (history, cmd) => {
|
|
482
|
+
errors.contents = [];
|
|
483
|
+
let state = Stdlib_Array.reduce(history, Behavior.initialState, Behavior.evolve);
|
|
484
|
+
let events = Behavior.decide(state, cmd);
|
|
485
|
+
if (events.TAG === "Ok") {
|
|
486
|
+
return events._0;
|
|
487
|
+
}
|
|
488
|
+
errors.contents = [events._0];
|
|
489
|
+
return [];
|
|
490
|
+
};
|
|
491
|
+
let thenEvent = (events, expectedEvent) => compareEvents(events, [expectedEvent]);
|
|
492
|
+
let thenCompareEvent = (events, expectedEvent, cmp) => compareEventsWith(events, [expectedEvent], cmp);
|
|
397
493
|
let thenError = (events, expectedError) => matchesError(events, [], expectedError);
|
|
398
494
|
let thenEventWithError = (events, expectedEvent, expectedError) => matchesError(events, [expectedEvent], expectedError);
|
|
399
495
|
let thenEventsWithError = matchesError;
|
|
@@ -405,10 +501,10 @@ function MakeFromAggregate(Spec) {
|
|
|
405
501
|
whenCmd: whenCmd,
|
|
406
502
|
thenEvent: thenEvent,
|
|
407
503
|
thenCompareEvent: thenCompareEvent,
|
|
408
|
-
thenNoEvent:
|
|
504
|
+
thenNoEvent: compareNoEvent,
|
|
409
505
|
thenEventWithError: thenEventWithError,
|
|
410
|
-
thenEvents:
|
|
411
|
-
thenCompareEvents:
|
|
506
|
+
thenEvents: compareEvents,
|
|
507
|
+
thenCompareEvents: compareEventsWith,
|
|
412
508
|
thenEventsWithError: thenEventsWithError,
|
|
413
509
|
thenError: thenError
|
|
414
510
|
};
|
|
@@ -420,6 +516,7 @@ export {
|
|
|
420
516
|
encodeQueryItem,
|
|
421
517
|
encodeQuery,
|
|
422
518
|
encodeAppendCondition,
|
|
519
|
+
AssertionCore,
|
|
423
520
|
Make,
|
|
424
521
|
MakeFromAggregate,
|
|
425
522
|
}
|