From 054913d17d1ad8e13b0aec221c0a9a2d9f315153 Mon Sep 17 00:00:00 2001 From: Robin Date: Thu, 3 Sep 2026 20:11:18 +0200 Subject: [PATCH] Use testScope in ObservableScope tests --- src/state/ObservableScope.test.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/state/ObservableScope.test.ts b/src/state/ObservableScope.test.ts index 12bd39ced..25bb14324 100644 --- a/src/state/ObservableScope.test.ts +++ b/src/state/ObservableScope.test.ts @@ -16,7 +16,7 @@ import { ObservableScope, trackEpoch, } from "./ObservableScope"; -import { withTestScheduler } from "../utils/test"; +import { testScope, withTestScheduler } from "../utils/test"; describe("Epoch", () => { it("should map the value correctly", () => { @@ -87,7 +87,7 @@ describe("Epoch", () => { }); it("behavior test", () => { - const scope = new ObservableScope(); + const scope = testScope(); const s$ = new Subject(); const behavior$ = scope.behavior(s$, 0); behavior$.subscribe((value) => { @@ -115,7 +115,7 @@ describe("Reconcile", () => { it("should wait clean up before processing next", async () => { vi.useFakeTimers(); - const scope = new ObservableScope(); + const scope = testScope(); const behavior$ = new BehaviorSubject(0); const setup = vi.fn().mockImplementation(async () => await sleep(100)); @@ -149,7 +149,7 @@ describe("Reconcile", () => { it("should skip intermediates values that are not setup", async () => { vi.useFakeTimers(); - const scope = new ObservableScope(); + const scope = testScope(); const behavior$ = new BehaviorSubject(0); const setup = vi @@ -194,7 +194,7 @@ describe("Reconcile", () => { it("should wait for setup to complete before starting cleanup", async () => { vi.useFakeTimers(); - const scope = new ObservableScope(); + const scope = testScope(); const behavior$ = new BehaviorSubject(0); const setup = vi @@ -241,7 +241,7 @@ describe("Reconcile", () => { describe("behavior", () => { it("warns with the tag and nesting depth, logging each new depth once", () => { const warn = vi.spyOn(logger, "warn").mockImplementation(() => {}); - const scope = new ObservableScope(); + const scope = testScope(); const source$ = new Subject(); const behavior$ = scope.behavior(source$, 0, "tagged"); // Re-enter once on value 1 (depth 2), then a nested re-entry on value 2 @@ -267,7 +267,6 @@ describe("behavior", () => { // left stranded on the oldest. expect(behavior$.value).toBe(3); expect(seen.at(-1)).toBe(1); - scope.end(); }); it("warns when the scope is ended while a behavior is mid-delivery", () => {