@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { Chunk, Context, Effect, identity, Option, Stream, SubscriptionRef } from "effect"
|
||||
import { Chunk, Context, Effect, Either, identity, Option, Stream, SubscriptionRef } from "effect"
|
||||
import * as Lens from "./Lens.js"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("Lens", () => {
|
||||
|
||||
const result = await Effect.runPromise(Effect.either(Lens.get(lens)))
|
||||
|
||||
expect(result.left).toBe("mapped:read")
|
||||
expect(result).toEqual(Either.left("mapped:read"))
|
||||
})
|
||||
|
||||
test("mapErrorWrite transforms modify errors", async () => {
|
||||
@@ -35,7 +35,7 @@ describe("Lens", () => {
|
||||
|
||||
const result = await Effect.runPromise(Effect.either(Lens.set(lens, 2)))
|
||||
|
||||
expect(result.left).toBe("mapped-write")
|
||||
expect(result).toEqual(Either.left("mapped-write"))
|
||||
})
|
||||
|
||||
test("mapError transforms read and modify errors", async () => {
|
||||
@@ -54,8 +54,8 @@ describe("Lens", () => {
|
||||
Effect.either(Lens.set(lens, 1)),
|
||||
] as const))
|
||||
|
||||
expect(result[0].left).toBe("mapped")
|
||||
expect(result[1].left).toBe("mapped")
|
||||
expect(result[0]).toEqual(Either.left("mapped"))
|
||||
expect(result[1]).toEqual(Either.left("mapped"))
|
||||
})
|
||||
|
||||
test("catchAllRead recovers from read failures", async () => {
|
||||
@@ -67,7 +67,8 @@ describe("Lens", () => {
|
||||
Lens.make<number, "read", never, never, never>({
|
||||
get: Effect.fail("read" as const),
|
||||
changes: Stream.fail("read" as const),
|
||||
set: () => Effect.void,
|
||||
commit: () => Effect.void,
|
||||
withLock: identity,
|
||||
}),
|
||||
() => Lens.fromSubscriptionRef(fallback),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user