-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.opencode.test.ts
More file actions
22 lines (17 loc) · 945 Bytes
/
Copy pathhooks.opencode.test.ts
File metadata and controls
22 lines (17 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { describe, expect, test } from "bun:test";
import { installOpenCodeHooks } from "../src/hooks/opencode";
describe("installOpenCodeHooks", () => {
test("writes a marked plugin file and is idempotent on re-run", async () => {
const dir = `/tmp/commitly-opencode-test-${Date.now()}`;
const outcome1 = await installOpenCodeHooks("project", dir);
expect(outcome1.events[0]!.status).toBe("installed");
const content = await Bun.file(outcome1.configPath).text();
expect(content).toContain("AUTO-GENERATED by `commitly init`");
expect(content).toContain("export const CommitlyPlugin");
const outcome2 = await installOpenCodeHooks("project", dir);
expect(outcome2.events[0]!.status).toBe("already-present");
const outcome3 = await installOpenCodeHooks("project", dir, { force: true });
expect(outcome3.events[0]!.status).toBe("replaced");
await Bun.$`rm -rf ${dir}`.quiet().nothrow();
});
});