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

96 lines
3.0 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { pack } from '../../../src/core/packager.js';
import { createMockConfig } from '../../testing/testUtils.js';
describe('packager split output', () => {
it('passes split output results correctly through the packager', async () => {
const processedFiles = [
{ path: 'a/file1.txt', content: '11111' },
{ path: 'b/file2.txt', content: '22222' },
];
const allFilePaths = ['a/file1.txt', 'b/file2.txt'];
const mockConfig = createMockConfig({
cwd: '/test',
output: {
filePath: 'repomix-output.xml',
splitOutput: 12,
copyToClipboard: false,
stdout: false,
git: {
includeDiffs: false,
includeLogs: false,
},
},
});
const produceOutput = vi.fn().mockResolvedValue({
outputFiles: ['repomix-output.1.xml', 'repomix-output.2.xml'],
outputForMetrics: ['x'.repeat(10), 'x'.repeat(10)],
});
const calculateMetrics = vi.fn().mockResolvedValue({
totalFiles: 2,
totalCharacters: 0,
totalTokens: 0,
fileCharCounts: {},
fileTokenCounts: {},
gitDiffTokenCount: 0,
gitLogTokenCount: 0,
});
const result = await pack(['root'], mockConfig, () => {}, {
searchFiles: vi.fn().mockResolvedValue({ filePaths: allFilePaths, emptyDirPaths: [] }),
sortPaths: vi.fn().mockImplementation((paths) => paths),
collectFiles: vi.fn().mockResolvedValue({ rawFiles: processedFiles, skippedFiles: [] }),
processFiles: vi.fn().mockReturnValue(processedFiles),
validateFileSafety: vi.fn().mockResolvedValue({
safeFilePaths: allFilePaths,
safeRawFiles: processedFiles,
suspiciousFilesResults: [],
suspiciousGitDiffResults: [],
suspiciousGitLogResults: [],
}),
getGitDiffs: vi.fn().mockResolvedValue(undefined),
getGitLogs: vi.fn().mockResolvedValue(undefined),
produceOutput,
calculateMetrics,
createMetricsTaskRunner: vi.fn().mockReturnValue({
taskRunner: {
run: vi.fn().mockResolvedValue(0),
cleanup: vi.fn().mockResolvedValue(undefined),
},
warmupPromise: Promise.resolve(),
}),
});
expect(produceOutput).toHaveBeenCalledWith(
['root'],
mockConfig,
processedFiles,
allFilePaths,
undefined,
undefined,
expect.any(Function),
[{ rootLabel: 'root', files: allFilePaths }],
undefined,
);
expect(calculateMetrics).toHaveBeenCalledWith(
processedFiles,
expect.anything(),
expect.anything(),
mockConfig,
undefined,
undefined,
expect.objectContaining({ taskRunner: expect.anything() }),
);
// Verify that calculateMetrics received a promise that resolves to the expected split output
const outputArg = calculateMetrics.mock.calls[0][1];
await expect(outputArg).resolves.toEqual(['x'.repeat(10), 'x'.repeat(10)]);
expect(result.outputFiles).toEqual(['repomix-output.1.xml', 'repomix-output.2.xml']);
});
});