feat(simulation): add literal screen text matching (#36085)
This commit is contained in:
parent
aa0e626b12
commit
855a9569b5
5 changed files with 45 additions and 0 deletions
11
packages/simulation/test/actions.test.ts
Normal file
11
packages/simulation/test/actions.test.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { matches } from "../src/frontend/actions"
|
||||
|
||||
test("matches literal screen text", () => {
|
||||
const harness = { screen: () => "OpenCode [ready].*" }
|
||||
|
||||
expect(matches(harness, "OpenCode")).toBe(true)
|
||||
expect(matches(harness, "[ready].*")).toBe(true)
|
||||
expect(matches(harness, "OpenCode.*ready")).toBe(false)
|
||||
expect(matches(harness, "opencode")).toBe(false)
|
||||
})
|
||||
21
packages/simulation/test/protocol.test.ts
Normal file
21
packages/simulation/test/protocol.test.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { Frontend } from "../src/protocol"
|
||||
|
||||
test("decodes ui.matches text params", () => {
|
||||
expect(
|
||||
Frontend.decodeRequest({
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "ui.matches",
|
||||
params: { text: "OpenCode [ready].*" },
|
||||
}),
|
||||
).toMatchObject({ method: "ui.matches", params: { text: "OpenCode [ready].*" } })
|
||||
expect(() =>
|
||||
Frontend.decodeRequest({
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "ui.matches",
|
||||
params: { pattern: "OpenCode.*" },
|
||||
}),
|
||||
).toThrow()
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue