mirror of
https://github.com/stablyai/orca.git
synced 2026-10-18 08:03:22 +00:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { toLinuxPath, toWindowsWslPath, parseWslPath } from './wsl'
|
|
|
|
describe('wsl path helpers', () => {
|
|
it('parses WSL UNC paths on Windows', () => {
|
|
const originalPlatform = process.platform
|
|
Object.defineProperty(process, 'platform', {
|
|
configurable: true,
|
|
value: 'win32'
|
|
})
|
|
|
|
try {
|
|
expect(parseWslPath('\\\\wsl.localhost\\Ubuntu\\home\\jin\\repo')).toEqual({
|
|
distro: 'Ubuntu',
|
|
linuxPath: '/home/jin/repo'
|
|
})
|
|
} finally {
|
|
Object.defineProperty(process, 'platform', {
|
|
configurable: true,
|
|
value: originalPlatform
|
|
})
|
|
}
|
|
})
|
|
|
|
it('converts Windows drive paths to /mnt paths for WSL commands', () => {
|
|
expect(toLinuxPath('C:\\Users\\jinwo\\git\\orca')).toBe('/mnt/c/Users/jinwo/git/orca')
|
|
})
|
|
|
|
it('converts /mnt drive paths back to native Windows form', () => {
|
|
expect(toWindowsWslPath('/mnt/c/Users/jinwo/git/orca', 'Ubuntu')).toBe(
|
|
'C:\\Users\\jinwo\\git\\orca'
|
|
)
|
|
})
|
|
})
|