0.2.0 #5
@@ -233,6 +233,31 @@ describe("Lens", () => {
|
|||||||
expect(result.count).toBe(iterations)
|
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 () => {
|
test("focusObjectOn focuses a nested property without touching other fields", async () => {
|
||||||
const [initialCount, updatedState] = await Effect.runPromise(
|
const [initialCount, updatedState] = await Effect.runPromise(
|
||||||
Effect.flatMap(
|
Effect.flatMap(
|
||||||
|
|||||||
Reference in New Issue
Block a user