/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/app/src/utils/refcount.test.ts
49 строк
1 KB
Luke Parker
fix(app): start MCP servers only for open directories (#28937)
29 май 2026, 00:51
Не верифицирован
29 май 2026, 00:51
e16bfd7
Код
Авторство
О чём код?
import { describe, expect, test } from "bun:test" import { createRoot } from "solid-js" import { createRefCountMap } from "./refcount" import { pathKey } from "./path-key" describe("createRefCountMap", () => { test("removes an item after its last owner is disposed", () => { const removed: string[] = [] const map = createRefCountMap( (key) => key, (key) => removed.push(key), ) const first = createRoot((dispose) => { map("/project") return dispose }) const second = createRoot((dispose) => { map("/project") return dispose }) first() expect(removed).toEqual([]) second() expect(removed).toEqual(["/project"]) }) test("keeps equivalent path consumers until the last owner is disposed", () => { const removed: string[] = [] const map = createRefCountMap( (key) => key, (key) => removed.push(key), pathKey, ) const first = createRoot((dispose) => { map("C:\\repo") return dispose }) const second = createRoot((dispose) => { map("C:/repo/") return dispose }) first() expect(removed).toEqual([]) second() expect(removed).toEqual(["C:/repo"]) }) })