51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { resolveFilePath } from '../../../src/renderer/store/utils/pathResolution';
|
|
|
|
describe('resolveFilePath', () => {
|
|
it('returns unix absolute paths as-is', () => {
|
|
expect(resolveFilePath('/repo', '/repo/src/index.ts')).toBe('/repo/src/index.ts');
|
|
});
|
|
|
|
it('returns windows absolute paths as-is', () => {
|
|
expect(resolveFilePath('C:\\repo', 'C:\\repo\\src\\index.ts')).toBe('C:\\repo\\src\\index.ts');
|
|
});
|
|
|
|
it('resolves dot-prefixed relative paths', () => {
|
|
expect(resolveFilePath('/repo', './src/app.ts')).toBe('/repo/src/app.ts');
|
|
});
|
|
|
|
it('resolves parent relative paths on unix', () => {
|
|
expect(resolveFilePath('/repo/apps/web', '../shared/file.ts')).toBe(
|
|
'/repo/apps/shared/file.ts'
|
|
);
|
|
});
|
|
|
|
it('resolves parent relative paths on windows', () => {
|
|
expect(resolveFilePath('C:\\repo\\apps\\web', '..\\shared\\file.ts')).toBe(
|
|
'C:\\repo\\apps\\shared\\file.ts'
|
|
);
|
|
});
|
|
|
|
it('passes through tilde paths as-is', () => {
|
|
expect(resolveFilePath('/repo', '~/some/directory')).toBe('~/some/directory');
|
|
});
|
|
|
|
it('passes through tilde paths with @ prefix as-is', () => {
|
|
expect(resolveFilePath('/repo', '@~/some/file.ts')).toBe('~/some/file.ts');
|
|
});
|
|
|
|
it('passes through bare tilde as-is', () => {
|
|
expect(resolveFilePath('/repo', '~')).toBe('~');
|
|
});
|
|
|
|
it('passes through tilde paths with backslash separator (Windows)', () => {
|
|
expect(resolveFilePath('C:\\repo', '~\\.claude\\agents\\file.md')).toBe(
|
|
'~\\.claude\\agents\\file.md'
|
|
);
|
|
});
|
|
|
|
it('does not treat tilde in the middle as special', () => {
|
|
expect(resolveFilePath('/repo', 'foo~/bar')).toBe('/repo/foo~/bar');
|
|
});
|
|
});
|