Files
oh-my-claudecode/dist/__tests__/bash-history.test.js
Yeachan-Heo 2b4490fc85 chore: include dist/ in git for seamless plugin installs
- Remove dist/ from .gitignore so compiled output ships with the repo
- Add linguist-generated attributes to hide dist/ from GitHub diffs
- Simplify update guide in all READMEs (no rebuild step needed)

Users no longer need to run npm install or rebuild after plugin
install/update — the compiled code is now included directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:50:26 +00:00

78 lines
3.1 KiB
JavaScript
Generated

/**
* Tests for bash history integration (issue #290)
*/
import { describe, it, expect, afterEach } from 'vitest';
import { existsSync, readFileSync, unlinkSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
describe('Bash History Integration', () => {
const testHistoryPath = join(tmpdir(), `.bash_history_test_${process.pid}`);
afterEach(() => {
try {
unlinkSync(testHistoryPath);
}
catch {
// Cleanup failure is non-critical
}
});
describe('appendToBashHistory logic', () => {
function appendToBashHistory(command, historyPath) {
if (!command || typeof command !== 'string')
return;
const cleaned = command.trim();
if (!cleaned)
return;
if (cleaned.startsWith('#'))
return;
const { appendFileSync } = require('fs');
appendFileSync(historyPath, cleaned + '\n');
}
it('should append a simple command', () => {
appendToBashHistory('ls -la', testHistoryPath);
const content = readFileSync(testHistoryPath, 'utf-8');
expect(content).toBe('ls -la\n');
});
it('should append multiple commands', () => {
appendToBashHistory('git status', testHistoryPath);
appendToBashHistory('npm test', testHistoryPath);
const content = readFileSync(testHistoryPath, 'utf-8');
expect(content).toBe('git status\nnpm test\n');
});
it('should trim whitespace', () => {
appendToBashHistory(' ls ', testHistoryPath);
const content = readFileSync(testHistoryPath, 'utf-8');
expect(content).toBe('ls\n');
});
it('should skip empty commands', () => {
appendToBashHistory('', testHistoryPath);
appendToBashHistory(' ', testHistoryPath);
expect(existsSync(testHistoryPath)).toBe(false);
});
it('should skip comments', () => {
appendToBashHistory('# this is a comment', testHistoryPath);
expect(existsSync(testHistoryPath)).toBe(false);
});
});
describe('config reading', () => {
function getBashHistoryEnabled(config) {
if (config === false)
return false;
if (typeof config === 'object' && config !== null && config.enabled === false)
return false;
return true;
}
it('should default to enabled when no config', () => {
expect(getBashHistoryEnabled(undefined)).toBe(true);
});
it('should respect false', () => {
expect(getBashHistoryEnabled(false)).toBe(false);
});
it('should respect { enabled: false }', () => {
expect(getBashHistoryEnabled({ enabled: false })).toBe(false);
});
it('should treat { enabled: true } as enabled', () => {
expect(getBashHistoryEnabled({ enabled: true })).toBe(true);
});
});
});
//# sourceMappingURL=bash-history.test.js.map