task ep.1.3.md
This commit is contained in:
31
src/features/foundation/business-events/replay.test.ts
Normal file
31
src/features/foundation/business-events/replay.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { assertReplayRequestIsScoped, createReplayPlan } from './replay.ts';
|
||||
import type { ReplaySource } from './types.ts';
|
||||
|
||||
const source: ReplaySource = {
|
||||
sourceName: 'test-source',
|
||||
async *listEvents() {}
|
||||
};
|
||||
|
||||
test('replay request requires organization scope and valid dates', () => {
|
||||
assert.doesNotThrow(() =>
|
||||
assertReplayRequestIsScoped({
|
||||
organizationId: 'org-1',
|
||||
occurredFrom: '2026-07-13T00:00:00.000Z'
|
||||
})
|
||||
);
|
||||
assert.throws(() => assertReplayRequestIsScoped({ organizationId: '' }), /organizationId/);
|
||||
assert.throws(
|
||||
() => assertReplayRequestIsScoped({ organizationId: 'org-1', occurredTo: 'bad-date' }),
|
||||
/valid ISO/
|
||||
);
|
||||
});
|
||||
|
||||
test('replay plan is dry-run and idempotent by default', () => {
|
||||
const plan = createReplayPlan({ organizationId: 'org-1' }, source);
|
||||
|
||||
assert.equal(plan.dryRun, true);
|
||||
assert.equal(plan.idempotencyRequired, true);
|
||||
assert.equal(plan.ordering, 'occurred_at_then_event_id');
|
||||
});
|
||||
Reference in New Issue
Block a user