-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathagentSkills.spec.ts
More file actions
71 lines (56 loc) · 2.28 KB
/
agentSkills.spec.ts
File metadata and controls
71 lines (56 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { expect } from "chai";
import * as sinon from "sinon";
import * as fs from "fs";
import * as path from "path";
import * as os from "os";
import * as utils from "./utils";
import * as prompt from "./prompt";
import { promptForAgentSkills, installAgentSkills } from "./agentSkills";
describe("agentSkills", () => {
let sandbox: sinon.SinonSandbox;
beforeEach(() => {
sandbox = sinon.createSandbox();
});
afterEach(() => {
sandbox.restore();
});
describe("promptForAgentSkills", () => {
it("should return true if user confirms", async () => {
sandbox.stub(prompt, "confirm").resolves(true);
const result = await promptForAgentSkills();
expect(result).to.be.true;
});
it("should return false if user declines", async () => {
sandbox.stub(prompt, "confirm").resolves(false);
const result = await promptForAgentSkills();
expect(result).to.be.false;
});
});
describe("installAgentSkills", () => {
let testRoot: string;
beforeEach(() => {
testRoot = fs.mkdtempSync(path.join(os.tmpdir(), "agent-skills-test-"));
});
afterEach(() => {
fs.rmSync(testRoot, { recursive: true, force: true });
});
it("should install skills locally and create .agents directory", async () => {
await installAgentSkills({ cwd: testRoot });
const agentsDir = path.join(testRoot, ".agents");
const skillsDir = path.join(agentsDir, "skills");
const lockFile = path.join(testRoot, "skills-lock.json");
expect(fs.existsSync(agentsDir), "Expected .agents directory to exist").to.be.true;
expect(fs.existsSync(skillsDir), "Expected .agents/skills directory to exist").to.be.true;
expect(fs.existsSync(lockFile), "Expected skills-lock.json to exist").to.be.true;
// Check if at least one skill was installed (e.g., firebase-basics)
const skills = fs.readdirSync(skillsDir);
expect(skills.length).to.be.greaterThan(0);
expect(skills).to.include("firebase-basics");
}).timeout(60000);
it("should skip if npx is not available", async () => {
sandbox.stub(utils, "commandExistsSync").withArgs("npx").returns(false);
await installAgentSkills({ cwd: testRoot });
expect(fs.existsSync(path.join(testRoot, ".agents"))).to.be.false;
});
});
});