summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/context/global-sync/utils.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/app/src/context/global-sync/utils.test.ts')
-rw-r--r--packages/app/src/context/global-sync/utils.test.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/app/src/context/global-sync/utils.test.ts b/packages/app/src/context/global-sync/utils.test.ts
index 6d44ac9a8..406c0f124 100644
--- a/packages/app/src/context/global-sync/utils.test.ts
+++ b/packages/app/src/context/global-sync/utils.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"
import type { Agent } from "@opencode-ai/sdk/v2/client"
-import { normalizeAgentList } from "./utils"
+import { directoryKey, normalizeAgentList } from "./utils"
const agent = (name = "build") =>
({
@@ -33,3 +33,20 @@ describe("normalizeAgentList", () => {
expect(normalizeAgentList([{ name: "build" }, agent("docs")])).toEqual([agent("docs")])
})
})
+
+describe("directoryKey", () => {
+ test("normalizes slashes", () => {
+ expect(String(directoryKey("C:\\Repos\\sst\\opencode"))).toBe("C:/Repos/sst/opencode")
+ expect(String(directoryKey("C:/Repos/sst/opencode"))).toBe("C:/Repos/sst/opencode")
+ })
+
+ test("preserves backslashes in posix paths", () => {
+ expect(String(directoryKey("/tmp/foo\\bar"))).toBe("/tmp/foo\\bar")
+ })
+
+ test("trims trailing slashes without breaking roots", () => {
+ expect(String(directoryKey("C:/Repos/sst/opencode/"))).toBe("C:/Repos/sst/opencode")
+ expect(String(directoryKey("C:/"))).toBe("C:/")
+ expect(String(directoryKey("/"))).toBe("/")
+ })
+})