-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathskill-generator-references-folder.test.js
More file actions
73 lines (62 loc) · 2.53 KB
/
skill-generator-references-folder.test.js
File metadata and controls
73 lines (62 loc) · 2.53 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
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdirSync, writeFileSync, readFileSync, existsSync, mkdtempSync, rmSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import { expandSkillGroups, generateSkill } from '../skill-generator.js';
function createFixture(tree, baseDir) {
for (const [name, content] of Object.entries(tree)) {
const fullPath = join(baseDir, name);
if (typeof content === 'string') {
writeFileSync(fullPath, content);
} else {
mkdirSync(fullPath, { recursive: true });
createFixture(content, fullPath);
}
}
}
describe('generateSkill local references', () => {
let tmpDir;
beforeEach(() => {
tmpDir = mkdtempSync(join(tmpdir(), 'skills-test-'));
mkdirSync(join(tmpDir, 'skills'));
});
afterEach(() => rmSync(tmpDir, { recursive: true, force: true }));
it('copies source references folder into generated references', async () => {
createFixture({
skills: {
integration: {
'description.md': '# Integration\n\n## Reference files\n\n{references}\n',
references: {
'product-analytics.md': '# Product analytics best practices\n\nDetails',
},
},
},
}, tmpDir);
const config = {
integration: {
type: 'docs-only',
template: 'description.md',
variants: [{ id: 'all', display_name: 'Integration' }],
},
};
const skill = expandSkillGroups(config, tmpDir)[0];
const outputDir = join(tmpDir, 'out');
await generateSkill({
skill,
version: 'test',
repoRoot: tmpDir,
configDir: tmpDir,
outputDir,
skipPatterns: { global: [], examples: {} },
commandmentsConfig: { commandments: {} },
skillTemplate: skill._template,
sharedDocs: skill._sharedDocs || [],
workflows: [],
});
const generatedRef = join(outputDir, 'integration', 'references', 'product-analytics.md');
const generatedSkill = join(outputDir, 'integration', 'SKILL.md');
expect(existsSync(generatedRef)).toBe(true);
expect(readFileSync(generatedRef, 'utf8')).toBe('# Product analytics best practices\n\nDetails');
expect(readFileSync(generatedSkill, 'utf8')).toContain('references/product-analytics.md');
});
});