fix(test): normalize path separators for Windows

This commit is contained in:
sahal 2026-04-28 11:01:26 -07:00
parent f5cbcb9d30
commit c78668aba8
3 changed files with 17 additions and 13 deletions

View file

@ -168,17 +168,18 @@ describe('group CLI', () => {
await runCommand(['group', 'repos', '/a', '/b', '--name', 'custom']);
expect(mockGroupService.groupDiscover).toHaveBeenCalledWith(
expect.objectContaining({
repoPaths: expect.arrayContaining([
expect.stringContaining('/a'),
expect.stringContaining('/b'),
]),
name: 'custom',
force: false,
skipSync: false,
}),
expect(mockGroupService.groupDiscover).toHaveBeenCalledTimes(1);
const callArg = mockGroupService.groupDiscover.mock.calls[0][0] as {
repoPaths: string[];
name: string;
force: boolean;
skipSync: boolean;
};
const normalizedPaths = callArg.repoPaths.map((p) => p.replace(/\\/g, '/'));
expect(normalizedPaths).toEqual(
expect.arrayContaining([expect.stringContaining('/a'), expect.stringContaining('/b')]),
);
expect(callArg).toMatchObject({ name: 'custom', force: false, skipSync: false });
});
});

View file

@ -155,7 +155,7 @@ describe('CodeDepExtractor', () => {
expect(consumers[0].contractId).toBe('lib::@acme/shared::formatDate');
expect(consumers[0].type).toBe('lib');
expect(consumers[0].role).toBe('consumer');
expect(consumers[0].symbolRef.filePath).toBe('src/app.ts');
expect(consumers[0].symbolRef.filePath.replace(/\\/g, '/')).toBe('src/app.ts');
expect(consumers[0].confidence).toBe(0.9);
expect(consumers[1].contractId).toBe('lib::@acme/shared::Logger');

View file

@ -220,7 +220,10 @@ import { Logger } from '@acme/shared/logging';
const results = await scanRepoForImports(tmpDir, targets);
expect(results).toHaveLength(2);
expect(results.map((r) => r.filePath).sort()).toEqual(['src/app.ts', 'src/utils/helper.ts']);
expect(results.map((r) => r.filePath.replace(/\\/g, '/')).sort()).toEqual([
'src/app.ts',
'src/utils/helper.ts',
]);
});
it('ignores node_modules', async () => {
@ -229,7 +232,7 @@ import { Logger } from '@acme/shared/logging';
const results = await scanRepoForImports(tmpDir, targets);
expect(results).toHaveLength(1);
expect(results[0].filePath).toBe('src/app.ts');
expect(results[0].filePath.replace(/\\/g, '/')).toBe('src/app.ts');
});
it('returns empty for empty target set', async () => {