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
125 lines
4.4 KiB
TypeScript
125 lines
4.4 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import type { RenderContext } from '../../../src/core/output/outputGeneratorTypes.js';
|
|
import {
|
|
generateFilesSection,
|
|
generateStructureSection,
|
|
generateSummarySection,
|
|
} from '../../../src/core/skill/skillSectionGenerators.js';
|
|
|
|
const createMockContext = (overrides: Partial<RenderContext> = {}): RenderContext => ({
|
|
generationHeader: 'Generated by Repomix',
|
|
summaryPurpose: 'This file contains a packed representation of the entire repository.',
|
|
summaryFileFormat: 'The content is organized as follows...',
|
|
summaryUsageGuidelines: 'Use this file as context for AI assistants.',
|
|
summaryNotes: 'Some files may have been excluded.',
|
|
headerText: '',
|
|
instruction: '',
|
|
treeString: 'src/\n index.ts\n utils.ts',
|
|
processedFiles: [
|
|
{ path: 'src/index.ts', content: 'console.log("hello");' },
|
|
{ path: 'src/utils.ts', content: 'export const sum = (a, b) => a + b;' },
|
|
],
|
|
fileLineCounts: {
|
|
'src/index.ts': 1,
|
|
'src/utils.ts': 1,
|
|
},
|
|
fileSummaryEnabled: true,
|
|
directoryStructureEnabled: true,
|
|
filesEnabled: true,
|
|
escapeFileContent: false,
|
|
markdownCodeBlockDelimiter: '```',
|
|
gitDiffEnabled: false,
|
|
gitDiffWorkTree: undefined,
|
|
gitDiffStaged: undefined,
|
|
gitLogEnabled: false,
|
|
gitLogContent: undefined,
|
|
gitLogCommits: undefined,
|
|
...overrides,
|
|
});
|
|
|
|
describe('skillSectionGenerators', () => {
|
|
describe('generateSummarySection', () => {
|
|
test('should generate summary section with all fields', () => {
|
|
const context = createMockContext();
|
|
const result = generateSummarySection(context);
|
|
|
|
expect(result).toContain('Generated by Repomix');
|
|
expect(result).toContain('# Summary');
|
|
expect(result).toContain('## Purpose');
|
|
expect(result).toContain('reference codebase organized into multiple files');
|
|
expect(result).toContain('## File Structure');
|
|
expect(result).toContain('project-structure.md');
|
|
expect(result).toContain('files.md');
|
|
expect(result).toContain('tech-stacks.md');
|
|
expect(result).toContain('summary.md');
|
|
expect(result).toContain('## Usage Guidelines');
|
|
expect(result).toContain('## Notes');
|
|
});
|
|
|
|
test('should include statistics section when provided', () => {
|
|
const context = createMockContext();
|
|
const statisticsSection = '## Statistics\n\n10 files | 500 lines';
|
|
const result = generateSummarySection(context, statisticsSection);
|
|
|
|
expect(result).toContain('## Statistics');
|
|
expect(result).toContain('10 files | 500 lines');
|
|
});
|
|
});
|
|
|
|
describe('generateStructureSection', () => {
|
|
test('should generate structure section with tree string', () => {
|
|
const context = createMockContext();
|
|
const result = generateStructureSection(context);
|
|
|
|
expect(result).toContain('# Directory Structure');
|
|
expect(result).toContain('```');
|
|
expect(result).toContain('src/');
|
|
expect(result).toContain('index.ts');
|
|
});
|
|
|
|
test('should return empty string when directory structure is disabled', () => {
|
|
const context = createMockContext({ directoryStructureEnabled: false });
|
|
const result = generateStructureSection(context);
|
|
|
|
expect(result).toBe('');
|
|
});
|
|
});
|
|
|
|
describe('generateFilesSection', () => {
|
|
test('should generate files section with all files', () => {
|
|
const context = createMockContext();
|
|
const result = generateFilesSection(context);
|
|
|
|
expect(result).toContain('# Files');
|
|
expect(result).toContain('## File: src/index.ts');
|
|
expect(result).toContain('console.log("hello");');
|
|
expect(result).toContain('## File: src/utils.ts');
|
|
expect(result).toContain('export const sum');
|
|
});
|
|
|
|
test('should include syntax highlighting language', () => {
|
|
const context = createMockContext();
|
|
const result = generateFilesSection(context);
|
|
|
|
expect(result).toContain('```typescript');
|
|
});
|
|
|
|
test('should return empty string when files are disabled', () => {
|
|
const context = createMockContext({ filesEnabled: false });
|
|
const result = generateFilesSection(context);
|
|
|
|
expect(result).toBe('');
|
|
});
|
|
|
|
test('should handle files without known extensions', () => {
|
|
const context = createMockContext({
|
|
processedFiles: [{ path: 'Dockerfile', content: 'FROM node:18' }],
|
|
});
|
|
const result = generateFilesSection(context);
|
|
|
|
expect(result).toContain('## File: Dockerfile');
|
|
expect(result).toContain('FROM node:18');
|
|
});
|
|
});
|
|
});
|