2026-04-12 02:30:01 +09:00
|
|
|
import { describe, expect, mock, test } from "bun:test"
|
|
|
|
|
|
|
|
|
|
import type { OpencodeClient } from "./opencode-client"
|
|
|
|
|
import { verifySessionExists } from "./session-existence"
|
2026-05-12 15:38:31 +09:00
|
|
|
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
|
2026-04-12 02:30:01 +09:00
|
|
|
|
|
|
|
|
describe("verifySessionExists", () => {
|
|
|
|
|
test("passes query directory to session lookup when provided", async () => {
|
|
|
|
|
// given
|
|
|
|
|
const get = mock(async () => ({ data: { id: "session-123" } }))
|
2026-05-12 15:38:31 +09:00
|
|
|
const client = unsafeTestValue<OpencodeClient>({
|
2026-04-12 02:30:01 +09:00
|
|
|
session: {
|
|
|
|
|
get,
|
|
|
|
|
},
|
2026-05-12 14:21:46 +09:00
|
|
|
})
|
2026-04-12 02:30:01 +09:00
|
|
|
|
|
|
|
|
// when
|
|
|
|
|
const result = await verifySessionExists(client, "session-123", "/project/root")
|
|
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
expect(result).toBe(true)
|
|
|
|
|
expect(get).toHaveBeenCalledWith({
|
|
|
|
|
path: { id: "session-123" },
|
|
|
|
|
query: { directory: "/project/root" },
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|