Files
bymyselfandGitHub 439707d56d Fix virtual env won't load on linux (#866)
* reset env in uv shell on linux

* update test

* revert env reset

* update test expectation

* target linux explicitly, preserve original fallback
2025-02-10 09:32:47 +11:00

44 lines
1.4 KiB
TypeScript

import os from 'node:os';
import { describe, expect, it, vi } from 'vitest';
import { getDefaultShell, getDefaultShellArgs } from '../../../src/shell/util';
vi.mock('node:os');
describe('shell utilities', () => {
describe('getDefaultShell', () => {
it('should return powershell path on Windows', () => {
vi.spyOn(os, 'platform').mockReturnValue('win32');
process.env.SYSTEMROOT = String.raw`C:\Windows`;
expect(getDefaultShell()).toBe(String.raw`C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`);
});
it('should return zsh on macOS', () => {
vi.spyOn(os, 'platform').mockReturnValue('darwin');
expect(getDefaultShell()).toBe('zsh');
});
it('should return bash on Linux', () => {
vi.spyOn(os, 'platform').mockReturnValue('linux');
expect(getDefaultShell()).toBe('bash');
});
});
describe('getDefaultShellArgs', () => {
it('should return ["-df"] on macOS', () => {
vi.spyOn(os, 'platform').mockReturnValue('darwin');
expect(getDefaultShellArgs()).toEqual(['-df']);
});
it('should return empty array on Windows', () => {
vi.spyOn(os, 'platform').mockReturnValue('win32');
expect(getDefaultShellArgs()).toEqual([]);
});
it('should return noprofile and norc on Linux', () => {
vi.spyOn(os, 'platform').mockReturnValue('linux');
expect(getDefaultShellArgs()).toEqual(['--noprofile', '--norc']);
});
});
});