semantics.test.ts 997 B

1234567891011121314151617181920212223
  1. import { expect, test } from "bun:test"
  2. import { BoxRenderable } from "@opentui/core"
  3. import { Effect } from "effect"
  4. import { SimulationSemantics as Reader } from "@opencode-ai/simulation/frontend/semantics"
  5. import { SimulationRenderer } from "@opencode-ai/simulation/frontend/renderer"
  6. import { SimulationSemantics } from "../../src/simulation/semantics"
  7. test("shares lazy semantic annotations with the simulation renderer", async () => {
  8. await Effect.runPromise(
  9. Effect.scoped(
  10. Effect.gen(function* () {
  11. const renderer = yield* SimulationRenderer.create({})
  12. const renderable = new BoxRenderable(renderer, { id: "permission" })
  13. let selected = false
  14. SimulationSemantics.bind(() => ({ role: "option", selected }))(renderable)
  15. expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: false })
  16. selected = true
  17. expect(Reader.read(renderable)?.()).toEqual({ role: "option", selected: true })
  18. }),
  19. ),
  20. )
  21. })