From 7ed5135aa6b9b78153727a423a893f5680640d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Thu, 28 May 2026 01:02:18 +0200 Subject: [PATCH] Add test --- packages/effect-lens/src/Lens.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/effect-lens/src/Lens.test.ts b/packages/effect-lens/src/Lens.test.ts index 8d84d2f..de10c5d 100644 --- a/packages/effect-lens/src/Lens.test.ts +++ b/packages/effect-lens/src/Lens.test.ts @@ -233,6 +233,31 @@ describe("Lens", () => { expect(result.count).toBe(iterations) }) + test("unwrap delegates reads, writes, and locking to the inner lens", async () => { + const iterations = 100 + + const result = await Effect.runPromise(Effect.flatMap( + SubscriptionRef.make(0), + parent => { + const lens = Lens.unwrap(Effect.succeed(Lens.fromSubscriptionRef(parent))) + + return Effect.flatMap( + Effect.forEach( + Array.from({ length: iterations }), + () => Lens.updateEffect( + lens, + count => Effect.as(Effect.yieldNow(), count + 1), + ), + { concurrency: "unbounded", discard: true }, + ), + () => Effect.all([Lens.get(lens), parent.get] as const), + ) + }, + )) + + expect(result).toEqual([iterations, iterations]) + }) + test("focusObjectOn focuses a nested property without touching other fields", async () => { const [initialCount, updatedState] = await Effect.runPromise( Effect.flatMap(