yamadashy--repomix
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
184 行
5.1 KiB
TypeScript
184 行
5.1 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { produceOutput } from '../../../src/core/packager/produceOutput.js';
|
|
import { createMockConfig } from '../../testing/testUtils.js';
|
|
|
|
describe('produceOutput', () => {
|
|
const createMockDeps = () => ({
|
|
generateOutput: vi.fn().mockResolvedValue('generated output'),
|
|
writeOutputToDisk: vi.fn().mockResolvedValue(undefined),
|
|
copyToClipboardIfEnabled: vi.fn().mockResolvedValue(undefined),
|
|
});
|
|
|
|
describe('single output mode', () => {
|
|
it('generates and writes single output file', async () => {
|
|
const mockDeps = createMockDeps();
|
|
const mockConfig = createMockConfig();
|
|
const processedFiles = [{ path: 'file.ts', content: 'content' }];
|
|
const allFilePaths = ['file.ts'];
|
|
const progressCallback = vi.fn();
|
|
|
|
const result = await produceOutput(
|
|
['/root'],
|
|
mockConfig,
|
|
processedFiles,
|
|
allFilePaths,
|
|
undefined,
|
|
undefined,
|
|
progressCallback,
|
|
undefined,
|
|
undefined,
|
|
mockDeps,
|
|
);
|
|
|
|
expect(mockDeps.generateOutput).toHaveBeenCalledWith(
|
|
['/root'],
|
|
mockConfig,
|
|
processedFiles,
|
|
allFilePaths,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
undefined,
|
|
);
|
|
expect(mockDeps.writeOutputToDisk).toHaveBeenCalledWith('generated output', mockConfig);
|
|
expect(mockDeps.copyToClipboardIfEnabled).toHaveBeenCalledWith('generated output', progressCallback, mockConfig);
|
|
expect(result).toEqual({
|
|
outputForMetrics: 'generated output',
|
|
});
|
|
expect(result.outputFiles).toBeUndefined();
|
|
});
|
|
|
|
it('passes git diff and log results to generateOutput', async () => {
|
|
const mockDeps = createMockDeps();
|
|
const mockConfig = createMockConfig();
|
|
const gitDiffResult = { workTreeDiffContent: 'diff', stagedDiffContent: '' };
|
|
const gitLogResult = { logContent: 'logs', commits: [] };
|
|
|
|
await produceOutput(
|
|
['/root'],
|
|
mockConfig,
|
|
[],
|
|
[],
|
|
gitDiffResult as Parameters<typeof produceOutput>[4],
|
|
gitLogResult as Parameters<typeof produceOutput>[5],
|
|
vi.fn(),
|
|
undefined,
|
|
undefined,
|
|
mockDeps,
|
|
);
|
|
|
|
expect(mockDeps.generateOutput).toHaveBeenCalledWith(
|
|
['/root'],
|
|
mockConfig,
|
|
[],
|
|
[],
|
|
gitDiffResult,
|
|
gitLogResult,
|
|
undefined,
|
|
undefined,
|
|
);
|
|
});
|
|
|
|
it('calls progress callback with correct message', async () => {
|
|
const mockDeps = createMockDeps();
|
|
const mockConfig = createMockConfig();
|
|
const progressCallback = vi.fn();
|
|
|
|
await produceOutput(
|
|
['/root'],
|
|
mockConfig,
|
|
[],
|
|
[],
|
|
undefined,
|
|
undefined,
|
|
progressCallback,
|
|
undefined,
|
|
undefined,
|
|
mockDeps,
|
|
);
|
|
|
|
expect(progressCallback).toHaveBeenCalledWith('Writing output file...');
|
|
});
|
|
});
|
|
|
|
describe('split output mode', () => {
|
|
it('generates and writes multiple output files', async () => {
|
|
const mockDeps = createMockDeps();
|
|
mockDeps.generateOutput.mockImplementation(async (_rootDirs, _config, files) => {
|
|
return `output for ${files.length} files`;
|
|
});
|
|
|
|
const mockConfig = createMockConfig({
|
|
output: {
|
|
filePath: 'repomix-output.xml',
|
|
splitOutput: 1000000, // 1MB
|
|
},
|
|
});
|
|
|
|
const processedFiles = [
|
|
{ path: 'src/a.ts', content: 'content a' },
|
|
{ path: 'lib/b.ts', content: 'content b' },
|
|
];
|
|
const allFilePaths = ['src/a.ts', 'lib/b.ts'];
|
|
const progressCallback = vi.fn();
|
|
|
|
const result = await produceOutput(
|
|
['/root'],
|
|
mockConfig,
|
|
processedFiles,
|
|
allFilePaths,
|
|
undefined,
|
|
undefined,
|
|
progressCallback,
|
|
undefined,
|
|
undefined,
|
|
mockDeps,
|
|
);
|
|
|
|
expect(mockDeps.writeOutputToDisk).toHaveBeenCalled();
|
|
expect(result.outputFiles).toBeDefined();
|
|
expect(Array.isArray(result.outputForMetrics)).toBe(true);
|
|
});
|
|
|
|
it('calls progress callback for split output', async () => {
|
|
const mockDeps = createMockDeps();
|
|
const mockConfig = createMockConfig({
|
|
output: {
|
|
filePath: 'repomix-output.xml',
|
|
splitOutput: 1000000,
|
|
},
|
|
});
|
|
const progressCallback = vi.fn();
|
|
|
|
await produceOutput(
|
|
['/root'],
|
|
mockConfig,
|
|
[],
|
|
[],
|
|
undefined,
|
|
undefined,
|
|
progressCallback,
|
|
undefined,
|
|
undefined,
|
|
mockDeps,
|
|
);
|
|
|
|
expect(progressCallback).toHaveBeenCalledWith('Writing output files...');
|
|
});
|
|
|
|
it('does not call copyToClipboardIfEnabled in split mode', async () => {
|
|
const mockDeps = createMockDeps();
|
|
const mockConfig = createMockConfig({
|
|
output: {
|
|
filePath: 'repomix-output.xml',
|
|
splitOutput: 1000000,
|
|
},
|
|
});
|
|
|
|
await produceOutput(['/root'], mockConfig, [], [], undefined, undefined, vi.fn(), undefined, undefined, mockDeps);
|
|
|
|
expect(mockDeps.copyToClipboardIfEnabled).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|