Add tests
All checks were successful
Lint / lint (push) Successful in 14s

This commit is contained in:
Julien Valverdé
2026-03-24 11:39:06 +01:00
parent 6fa34069ea
commit 45bf604381

View File

@@ -96,4 +96,44 @@ describe("Lens", () => {
expect(Chunk.toReadonlyArray(updated)).toEqual([1, 2, 99])
})
// test("changes stream emits updates when lens mutates state", async () => {
// const events = await Effect.runPromise(
// Effect.flatMap(
// SubscriptionRef.make({ count: 0 }),
// parent => {
// const lens = Lens.mapField(Lens.fromSubscriptionRef(parent), "count")
// return Effect.fork(Stream.runCollect(Stream.take(lens.changes, 2))).pipe(
// Effect.tap(Lens.set(lens, 1)),
// Effect.tap(Lens.set(lens, 1)),
// Effect.andThen(Fiber.join),
// Effect.map(Chunk.toReadonlyArray),
// )
// },
// ),
// )
// expect(events).toEqual([1, 2])
// })
// test("mapped changes stream can derive transformed values", async () => {
// const derived = await Effect.runPromise(
// Effect.flatMap(
// SubscriptionRef.make({ count: 10 }),
// parent => {
// const lens = Lens.mapField(Lens.fromSubscriptionRef(parent), "count")
// const transformed = Stream.map(lens.changes, count => `count:${ count }`)
// return Effect.scoped(() => Effect.flatMap(
// Effect.forkScoped(Stream.runCollect(Stream.take(transformed, 1))),
// fiber => Effect.flatMap(
// Lens.set(lens, 42),
// () => Effect.join(fiber),
// ),
// ))
// },
// ),
// )
// expect(derived).toEqual(["count:42"])
// })
})