From 666674327f009e9b1013218fc384f193b64c6997 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 14 Dec 2025 22:39:18 -0800 Subject: Adds unit tests --- tst/test_utils.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tst/test_utils.ts (limited to 'tst/test_utils.ts') diff --git a/tst/test_utils.ts b/tst/test_utils.ts new file mode 100644 index 0000000..5c6237c --- /dev/null +++ b/tst/test_utils.ts @@ -0,0 +1,30 @@ +import { type ITrace, type ITraceWith, TraceableImpl } from '../lib/index'; + +export class CollectingTrace implements ITrace { + constructor( + private readonly collector: Array>> = [], + private readonly scopes: Array> = [], + ) {} + + public get events() { + return this.collector; + } + + public traceScope(trace: ITraceWith): ITrace { + return new CollectingTrace(this.collector, this.scopes.concat([trace])); + } + + public trace(trace: ITraceWith) { + this.collector.push(this.scopes.concat([trace])); + } +} + +export class TestTraceable extends TraceableImpl { + constructor(item: T, trace: ITrace) { + super(item, trace); + } + + static of(item: T, trace: ITrace) { + return new TestTraceable(item, trace); + } +} -- cgit v1.2.3-70-g09d2