Files
ruflo/v2/tests/unit/cli/simple-commands/monitor.test.js
T
rUvandClaude Opus 4.5 1b6a1971f7 feat(v3): add comprehensive v3 implementation plans and swarm architecture
- Reorganize v3/ into implementation/ subfolders:
  - planning/, architecture/, migration/, integration/
  - security/, adrs/, research/, swarm-plans/

- Add 15-agent concurrent swarm implementation plans:
  - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases
  - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities
  - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology
  - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x)
  - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback
  - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies

- Update .claude/settings.json with proper hooks format
- Add bash aliases for claude --dangerously-skip-permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:40:51 +00:00

87 lines
2.8 KiB
JavaScript

import { jest, describe, test, beforeEach, afterEach, expect } from '@jest/globals';
describe('monitor.js - Real Metrics Implementation', () => {
let consoleSpy;
let processExitSpy;
beforeEach(() => {
// Setup console spies
consoleSpy = {
log: jest.spyOn(console, 'log').mockImplementation(),
clear: jest.spyOn(console, 'clear').mockImplementation(),
error: jest.spyOn(console, 'error').mockImplementation()
};
// Setup process spies
processExitSpy = jest.spyOn(process, 'exit').mockImplementation();
});
afterEach(() => {
// Restore all spies
Object.values(consoleSpy).forEach(spy => spy.mockRestore());
processExitSpy.mockRestore();
});
describe('Basic Functionality', () => {
test('should import without errors', async () => {
const monitor = await import('../../../../src/cli/simple-commands/monitor.js');
expect(monitor.monitorCommand).toBeDefined();
expect(monitor.showMonitorHelp).toBeDefined();
});
test('should collect and display metrics', async () => {
const { monitorCommand } = await import('../../../../src/cli/simple-commands/monitor.js');
await monitorCommand([], {});
// Check if metrics were displayed
const output = consoleSpy.log.mock.calls.join('\n');
expect(output).toContain('System Metrics');
});
test('should show help information', async () => {
const { showMonitorHelp } = await import('../../../../src/cli/simple-commands/monitor.js');
showMonitorHelp();
const output = consoleSpy.log.mock.calls.join('\n');
expect(output).toContain('Monitor commands:');
expect(output).toContain('--interval');
expect(output).toContain('--format');
});
});
describe('Output Formats', () => {
test('should output JSON format when specified', async () => {
const { monitorCommand } = await import('../../../../src/cli/simple-commands/monitor.js');
await monitorCommand(['--format', 'json'], {});
const calls = consoleSpy.log.mock.calls;
const jsonOutput = calls.find(call => {
try {
JSON.parse(call[0]);
return true;
} catch {
return false;
}
});
expect(jsonOutput).toBeDefined();
if (jsonOutput) {
const parsed = JSON.parse(jsonOutput[0]);
expect(parsed).toHaveProperty('timestamp');
expect(parsed).toHaveProperty('system');
}
});
test('should output pretty format by default', async () => {
const { monitorCommand } = await import('../../../../src/cli/simple-commands/monitor.js');
await monitorCommand([], {});
const output = consoleSpy.log.mock.calls.join('\n');
expect(output).toMatch(/System Metrics|System Resources|Performance/);
});
});
});