Files
wehub-resource-sync 719032b19f
Update Schema / Update configuration json schema (push) Has been cancelled
Memory Benchmark / Memory Test (Full Analysis) (push) Has been cancelled
CI Quality / Lint GitHub Actions (actionlint) (push) Has been cancelled
CI Quality / Lint GitHub Actions (zizmor) (push) Has been cancelled
CI Quality / Check typos (push) Has been cancelled
CI / Test coverage (push) Has been cancelled
CI / Test (22.x, windows-latest) (push) Has been cancelled
CI / Test (24.x, macos-latest) (push) Has been cancelled
CI / Test (24.x, ubuntu-latest) (push) Has been cancelled
CI / Test (24.x, windows-latest) (push) Has been cancelled
CI / Test (26.x, macos-latest) (push) Has been cancelled
CI / Test (26.x, ubuntu-latest) (push) Has been cancelled
CI / Test (26.x, windows-latest) (push) Has been cancelled
CI / Test with Bun (latest, macos-latest) (push) Has been cancelled
CI / Test with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Test with Bun (latest, windows-latest) (push) Has been cancelled
CI / Build and run (22.x, macos-latest) (push) Has been cancelled
CI / Build and run (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (22.x, windows-latest) (push) Has been cancelled
autofix.ci / autofix (push) Has been cancelled
CI Browser Extension / Lint Browser Extension (push) Has been cancelled
CI Browser Extension / Test Browser Extension (push) Has been cancelled
Memory Benchmark / Memory Test (push) Has been cancelled
CI Website / Lint Website Client (push) Has been cancelled
CI Website / Lint Website Server (push) Has been cancelled
CI Website / Test Website Server (push) Has been cancelled
CI Website / Bundle Website Server (push) Has been cancelled
CI / Lint Biome (push) Has been cancelled
CI / Lint oxlint (push) Has been cancelled
CI / Lint TypeScript (push) Has been cancelled
CI / Lint Secretlint (push) Has been cancelled
CI / Test (22.x, macos-latest) (push) Has been cancelled
CI / Test (22.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, macos-latest) (push) Has been cancelled
CI / Build and run (24.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (24.x, windows-latest) (push) Has been cancelled
CI / Build and run (26.x, macos-latest) (push) Has been cancelled
CI / Build and run (26.x, ubuntu-latest) (push) Has been cancelled
CI / Build and run (26.x, windows-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, macos-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, ubuntu-latest) (push) Has been cancelled
CI / Build and run with Bun (latest, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Docker / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Docker / build (linux/arm/v7, ubuntu-24.04-arm) (push) Has been cancelled
Docker / build (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Docker / merge (push) Has been cancelled
Pack repository with Repomix / pack-repo (push) Has been cancelled
Performance Benchmark History / Benchmark (macos-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (ubuntu-latest) (push) Has been cancelled
Performance Benchmark History / Benchmark (windows-latest) (push) Has been cancelled
Performance Benchmark History / Store Results (push) Has been cancelled
Test Repomix Action / Test Node.js 22 (push) Has been cancelled
Test Repomix Action / Test Node.js 24 (push) Has been cancelled
Test Repomix Action / Test Node.js 26 (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:37 +08:00

118 lines
4.3 KiB
TypeScript

import { describe, expect, test } from 'vitest';
import { generateSkillMd, getSkillTemplate } from '../../../src/core/skill/skillStyle.js';
describe('skillStyle', () => {
describe('getSkillTemplate', () => {
test('should return valid SKILL.md template', () => {
const template = getSkillTemplate();
expect(template).toContain('---');
expect(template).toContain('name:');
expect(template).toContain('description:');
expect(template).toContain('# ');
expect(template).toContain('references/');
});
test('should include files table with contents column', () => {
const template = getSkillTemplate();
expect(template).toContain('## Files');
expect(template).toContain('| File | Contents |');
});
test('should include how to use section with numbered steps', () => {
const template = getSkillTemplate();
expect(template).toContain('## How to Use');
expect(template).toContain('### 1. Find file locations');
expect(template).toContain('### 2. Read file contents');
expect(template).toContain('### 3. Search for code');
});
test('should include overview and common use cases', () => {
const template = getSkillTemplate();
expect(template).toContain('## Overview');
expect(template).toContain('## Common Use Cases');
expect(template).toContain('## Tips');
});
test('should reference multiple files', () => {
const template = getSkillTemplate();
expect(template).toContain('references/summary.md');
expect(template).toContain('references/project-structure.md');
expect(template).toContain('references/files.md');
});
});
describe('generateSkillMd', () => {
const createTestContext = (overrides = {}) => ({
skillName: 'test-skill',
skillDescription: 'Test description',
projectName: 'Test Project',
totalFiles: 1,
totalLines: 100,
totalTokens: 100,
hasTechStack: false,
...overrides,
});
test('should generate SKILL.md with all fields', () => {
const context = createTestContext({
skillName: 'my-project-skill',
skillDescription: 'Reference codebase for My Project.',
projectName: 'My Project',
totalFiles: 42,
totalLines: 1000,
totalTokens: 12345,
});
const result = generateSkillMd(context);
// Check YAML frontmatter
expect(result).toContain('---');
expect(result).toContain('name: my-project-skill');
expect(result).toContain('description: Reference codebase for My Project.');
// Check content
expect(result).toContain('# My Project Codebase Reference');
expect(result).toContain('42 files');
expect(result).toContain('12345 tokens');
});
test('should end with newline', () => {
const result = generateSkillMd(createTestContext());
expect(result.endsWith('\n')).toBe(true);
});
test('should include references to multiple files', () => {
const result = generateSkillMd(createTestContext());
expect(result).toContain('`references/summary.md`');
expect(result).toContain('`references/project-structure.md`');
expect(result).toContain('`references/files.md`');
});
test('should not include git sections (skill output is for reference codebases)', () => {
const result = generateSkillMd(createTestContext());
expect(result).not.toContain('git-diffs.md');
expect(result).not.toContain('git-logs.md');
});
test('should include tech-stack reference when hasTechStack is true', () => {
const result = generateSkillMd(createTestContext({ hasTechStack: true }));
expect(result).toContain('`references/tech-stacks.md`');
});
test('should not include tech-stack reference when hasTechStack is false', () => {
const result = generateSkillMd(createTestContext({ hasTechStack: false }));
expect(result).not.toContain('tech-stacks.md');
});
test('should not include statistics section (moved to summary.md)', () => {
const result = generateSkillMd(createTestContext());
expect(result).not.toContain('## Statistics');
});
test('should include total lines in header', () => {
const result = generateSkillMd(createTestContext({ totalLines: 5000 }));
expect(result).toContain('5000 lines');
});
});
});