Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/core/completions/installers/zsh-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ import { ZshInstaller } from '../../../../src/core/completions/installers/zsh-in
describe('ZshInstaller', () => {
let testHomeDir: string;
let installer: ZshInstaller;
let originalZsh: string | undefined;

beforeEach(async () => {
// Clear $ZSH (set by a real Oh My Zsh install) so isOhMyZshInstalled()
// falls through to the isolated test home directory
originalZsh = process.env.ZSH;
delete process.env.ZSH;

// Create a temporary home directory for testing
testHomeDir = path.join(os.tmpdir(), `openspec-zsh-test-${randomUUID()}`);
await fs.mkdir(testHomeDir, { recursive: true });
installer = new ZshInstaller(testHomeDir);
});

afterEach(async () => {
// Restore original environment
if (originalZsh !== undefined) {
process.env.ZSH = originalZsh;
} else {
delete process.env.ZSH;
}

// Clean up test directory
await fs.rm(testHomeDir, { recursive: true, force: true });
});
Expand All @@ -27,6 +40,14 @@ describe('ZshInstaller', () => {
expect(isInstalled).toBe(false);
});

it('should return true when $ZSH environment variable is set', async () => {
// No .oh-my-zsh directory in testHomeDir; detection relies on $ZSH alone
process.env.ZSH = path.join(testHomeDir, '.oh-my-zsh');

const isInstalled = await installer.isOhMyZshInstalled();
expect(isInstalled).toBe(true);
});

it('should return true when Oh My Zsh directory exists', async () => {
// Create .oh-my-zsh directory
const ohMyZshPath = path.join(testHomeDir, '.oh-my-zsh');
Expand Down
Loading