-
-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathhermesagent-skill.test.ts
More file actions
104 lines (91 loc) · 3.36 KB
/
Copy pathhermesagent-skill.test.ts
File metadata and controls
104 lines (91 loc) · 3.36 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { HERMESAGENT_SKILLS_DIR_PATH } from "../../constants/hermesagent-paths.js";
import { RULESYNC_SKILLS_RELATIVE_DIR_PATH } from "../../constants/rulesync-paths.js";
import { setupTestDirectory } from "../../test-utils/test-directories.js";
import { HermesagentSkill } from "./hermesagent-skill.js";
import { RulesyncSkill } from "./rulesync-skill.js";
describe("HermesagentSkill", () => {
let testDir: string;
let cleanup: () => Promise<void>;
beforeEach(async () => {
const testSetup = await setupTestDirectory();
testDir = testSetup.testDir;
cleanup = testSetup.cleanup;
vi.spyOn(process, "cwd").mockReturnValue(testDir);
});
afterEach(async () => {
await cleanup();
vi.restoreAllMocks();
});
describe("getSettablePaths", () => {
it("should return the Hermes skills directory as relativeDirPath", () => {
const paths = HermesagentSkill.getSettablePaths();
expect(paths.relativeDirPath).toBe(HERMESAGENT_SKILLS_DIR_PATH);
});
});
describe("constructor", () => {
it("should force the Hermes skills directory even when another relativeDirPath is passed", () => {
const skill = new HermesagentSkill({
outputRoot: testDir,
relativeDirPath: "ignored",
dirName: "test-skill",
frontmatter: {
name: "Test Skill",
description: "Test skill description",
},
body: "This is the body of the Hermes skill.",
validate: true,
});
expect(skill).toBeInstanceOf(HermesagentSkill);
expect(skill.getRelativeDirPath()).toBe(HERMESAGENT_SKILLS_DIR_PATH);
expect(skill.getBody()).toBe("This is the body of the Hermes skill.");
expect(skill.getFrontmatter()).toEqual({
name: "Test Skill",
description: "Test skill description",
});
});
});
describe("fromRulesyncSkill", () => {
it("should create an instance routed to the Hermes skills directory", () => {
const rulesyncSkill = new RulesyncSkill({
outputRoot: testDir,
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH,
dirName: "test-skill",
frontmatter: {
name: "Test Skill",
description: "Test skill description",
},
body: "Test body content",
validate: true,
});
const skill = HermesagentSkill.fromRulesyncSkill({ rulesyncSkill, global: true });
expect(skill).toBeInstanceOf(HermesagentSkill);
expect(skill.getRelativeDirPath()).toBe(HERMESAGENT_SKILLS_DIR_PATH);
expect(skill.getBody()).toBe("Test body content");
expect(skill.getFrontmatter()).toEqual({
name: "Test Skill",
description: "Test skill description",
});
});
});
describe("toRulesyncSkill", () => {
it("should convert back to a RulesyncSkill", () => {
const skill = new HermesagentSkill({
outputRoot: testDir,
dirName: "test-skill",
frontmatter: {
name: "Test Skill",
description: "Test description",
},
body: "Test body",
validate: true,
});
const rulesyncSkill = skill.toRulesyncSkill();
expect(rulesyncSkill.getFrontmatter()).toMatchObject({
name: "Test Skill",
description: "Test description",
});
expect(rulesyncSkill.getBody()).toBe("Test body");
});
});
});