@rotorsoft/act-tck 2.1.0 → 2.1.2

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/index.js CHANGED
@@ -133,7 +133,7 @@ var runCacheDifferentialTck = (options) => {
133
133
  };
134
134
 
135
135
  // src/cache-tck.ts
136
- import { afterEach, beforeEach as beforeEach2, describe as describe2, expect as expect2, it as it2 } from "vitest";
136
+ import { afterEach, beforeEach, describe as describe2, expect as expect2, it as it2 } from "vitest";
137
137
  var entry = (event_id, state2 = {}, stream = `s-${event_id}`) => ({
138
138
  stream,
139
139
  state: state2,
@@ -145,7 +145,7 @@ var entry = (event_id, state2 = {}, stream = `s-${event_id}`) => ({
145
145
  var runCacheTck = (options) => {
146
146
  describe2(`TCK / Cache / ${options.name}`, () => {
147
147
  let cache;
148
- beforeEach2(() => {
148
+ beforeEach(() => {
149
149
  cache = options.factory();
150
150
  });
151
151
  afterEach(async () => {
@@ -221,7 +221,7 @@ var COUNTER_EVENT_NAMES = [
221
221
  ];
222
222
 
223
223
  // src/logger-differential-tck.ts
224
- import { afterEach as afterEach2, beforeEach as beforeEach3, describe as describe3, expect as expect3, it as it3 } from "vitest";
224
+ import { afterEach as afterEach2, beforeEach as beforeEach2, describe as describe3, expect as expect3, it as it3 } from "vitest";
225
225
  var LEVELS = ["fatal", "error", "warn", "info", "debug", "trace"];
226
226
  var drive = (logger) => {
227
227
  const out = [];
@@ -256,7 +256,7 @@ var runLoggerDifferentialTck = (options) => {
256
256
  describe3(`TCK / Logger differential / ${options.name}`, () => {
257
257
  let live = [];
258
258
  let original_stdout;
259
- beforeEach3(() => {
259
+ beforeEach2(() => {
260
260
  live = options.loggers.map((spec) => ({
261
261
  name: spec.name,
262
262
  logger: spec.factory()
@@ -281,13 +281,13 @@ var runLoggerDifferentialTck = (options) => {
281
281
  };
282
282
 
283
283
  // src/logger-tck.ts
284
- import { afterEach as afterEach3, beforeEach as beforeEach4, describe as describe4, expect as expect4, it as it4 } from "vitest";
284
+ import { afterEach as afterEach3, beforeEach as beforeEach3, describe as describe4, expect as expect4, it as it4 } from "vitest";
285
285
  var LEVELS2 = ["fatal", "error", "warn", "info", "debug", "trace"];
286
286
  var runLoggerTck = (options) => {
287
287
  describe4(`TCK / Logger / ${options.name}`, () => {
288
288
  let logger;
289
289
  let original_stdout;
290
- beforeEach4(() => {
290
+ beforeEach3(() => {
291
291
  logger = options.factory();
292
292
  original_stdout = process.stdout.write.bind(process.stdout);
293
293
  process.stdout.write = (() => true);
@@ -1104,7 +1104,15 @@ import {
1104
1104
  ValidationError
1105
1105
  } from "@rotorsoft/act";
1106
1106
  import { isStreamName } from "@rotorsoft/act/adapter";
1107
- import { afterAll as afterAll4, beforeAll as beforeAll4, describe as describe8, expect as expect8, it as it7, vi } from "vitest";
1107
+ import {
1108
+ afterAll as afterAll4,
1109
+ beforeAll as beforeAll4,
1110
+ beforeEach as beforeEach4,
1111
+ describe as describe8,
1112
+ expect as expect8,
1113
+ it as it7,
1114
+ vi
1115
+ } from "vitest";
1108
1116
  import { z as z2 } from "zod";
1109
1117
  var runStoreTck = (options) => {
1110
1118
  describe8(`TCK / Store / ${options.name}`, () => {
@@ -5402,7 +5410,7 @@ var runStoreTck = (options) => {
5402
5410
  expect8(next.id).toBeGreaterThan(head);
5403
5411
  });
5404
5412
  });
5405
- beforeEach(async () => {
5413
+ beforeEach4(async () => {
5406
5414
  await store.drop();
5407
5415
  await store.seed();
5408
5416
  });
@@ -5701,22 +5709,18 @@ var runStoreTck = (options) => {
5701
5709
  expect8(back[1].meta.causation.event?.id).toBe(back[0].id);
5702
5710
  expect8(back[2].meta.causation.event?.id).toBe(back[1].id);
5703
5711
  });
5704
- it7("leaves causation refs unmapped when the target isn't in the source", async () => {
5712
+ it7("gives a cause missing from the source id -1, so it names no restored event", async () => {
5705
5713
  const s = `restore-orphan-${uid()}`;
5706
5714
  const t = /* @__PURE__ */ new Date("2020-09-01T00:00:00.000Z");
5707
5715
  await restore(
5708
5716
  as_source([
5717
+ event(5, s, 0, "Incremented", t, { amount: 1 }),
5709
5718
  {
5710
- id: 1,
5711
- stream: s,
5712
- version: 0,
5713
- name: "Incremented",
5714
- data: { amount: 1 },
5715
- created: t,
5719
+ ...event(6, s, 1, "Incremented", t, { amount: 1 }),
5716
5720
  meta: {
5717
5721
  correlation: "c",
5718
5722
  causation: {
5719
- event: { id: 999, name: "Phantom", stream: "ghost" }
5723
+ event: { id: 1, name: "Pruned", stream: "ghost" }
5720
5724
  }
5721
5725
  }
5722
5726
  }
@@ -5729,7 +5733,11 @@ var runStoreTck = (options) => {
5729
5733
  },
5730
5734
  { stream: s, stream_exact: true }
5731
5735
  );
5732
- expect8(back[0].meta.causation.event?.id).toBe(999);
5736
+ expect8(back[1].meta.causation.event).toEqual({
5737
+ id: -1,
5738
+ name: "Pruned",
5739
+ stream: "ghost"
5740
+ });
5733
5741
  });
5734
5742
  it7("rolls back atomically when the source throws mid-iteration", async () => {
5735
5743
  const original = `restore-pre-${uid()}`;