skillhub/skillhub-cli/tests/installer.test.ts
chenbaowang 6c0d4f4f16 feat(skillhub-cli): add skillhub CLI with interactive multi-agent support
- Interactive agent selection for install/uninstall/list
- Namespace search selection for unspecified namespace
- --skill-version option to skip interactive selection
- --from option for local/github source installation
- Remove deprecated add command (use install --from instead)
- Path-based grouping for uninstall results
2026-04-14 10:21:09 +08:00

35 lines
1.2 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { installSkill } from "../src/core/installer.js";
import { mkdirSync, writeFileSync, rmSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
describe("installSkill", () => {
let tempDir: string;
let skillDir: string;
let targetDir: string;
beforeEach(() => {
tempDir = join(tmpdir(), "installer-test-" + Date.now());
skillDir = join(tempDir, "source-skill");
targetDir = tempDir;
mkdirSync(skillDir, { recursive: true });
writeFileSync(join(skillDir, "SKILL.md"), "# Test Skill\n");
});
afterEach(() => {
try { rmSync(tempDir, { recursive: true, force: true }); } catch {}
});
it("should return correct mode when mode is 'symlink'", () => {
const result = installSkill(skillDir, "test-skill", "claude-code", targetDir, "symlink", false);
expect(result.mode).toBe("symlink");
expect(result.success).toBe(true);
});
it("should return correct mode when mode is 'copy'", () => {
const result = installSkill(skillDir, "test-skill", "claude-code", targetDir, "copy", false);
expect(result.mode).toBe("copy");
expect(result.success).toBe(true);
});
});