mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-17 10:02:51 +00:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { describe, expect, test } from "bun:test"
|
|
import { createRefreshQueue } from "./queue"
|
|
import { directoryKey } from "./utils"
|
|
|
|
const tick = () => new Promise((resolve) => setTimeout(resolve, 10))
|
|
|
|
describe("createRefreshQueue", () => {
|
|
test("clears queued directories by normalized key", async () => {
|
|
const calls: string[] = []
|
|
const queue = createRefreshQueue({
|
|
paused: () => false,
|
|
key: directoryKey,
|
|
bootstrap: async () => {},
|
|
bootstrapInstance: (directory) => {
|
|
calls.push(directory)
|
|
},
|
|
})
|
|
|
|
queue.push("C:\\tmp\\demo")
|
|
queue.clear("C:/tmp/demo")
|
|
|
|
await tick()
|
|
|
|
expect(calls).toEqual([])
|
|
queue.dispose()
|
|
})
|
|
|
|
test("passes the original directory to bootstrapInstance", async () => {
|
|
const calls: string[] = []
|
|
const queue = createRefreshQueue({
|
|
paused: () => false,
|
|
key: directoryKey,
|
|
bootstrap: async () => {},
|
|
bootstrapInstance: (directory) => {
|
|
calls.push(directory)
|
|
},
|
|
})
|
|
|
|
queue.push("C:\\tmp\\demo")
|
|
|
|
await tick()
|
|
|
|
expect(calls).toEqual(["C:\\tmp\\demo"])
|
|
queue.dispose()
|
|
})
|
|
})
|