add rules command test

This commit is contained in:
Joe Danziger
2025-05-11 15:23:16 -04:00
parent e3f4cb155a
commit 937bbe1d6b

View File

@@ -1082,3 +1082,41 @@ describe('Update check', () => {
expect(consoleLogSpy.mock.calls[0][0]).toContain('1.1.0');
});
});
// -----------------------------------------------------------------------------
// Rules command tests (add/remove)
// -----------------------------------------------------------------------------
describe('rules command', () => {
let program;
let mockConsoleLog;
let mockConsoleError;
let mockExit;
beforeEach(() => {
jest.clearAllMocks();
program = setupCLI();
mockConsoleLog = jest.spyOn(console, 'log').mockImplementation(() => {});
mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => {});
mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {});
});
test('should handle rules add <brand> command', async () => {
// Simulate: task-master rules add roo
await program.parseAsync(['rules', 'add', 'roo'], { from: 'user' });
// Expect some log output indicating success
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringMatching(/adding rules for brand: roo/i));
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringMatching(/completed adding rules for brand: roo/i));
// Should not exit with error
expect(mockExit).not.toHaveBeenCalledWith(1);
});
test('should handle rules remove <brand> command', async () => {
// Simulate: task-master rules remove roo
await program.parseAsync(['rules', 'remove', 'roo'], { from: 'user' });
// Expect some log output indicating removal
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringMatching(/removing rules for brand: roo/i));
expect(mockConsoleLog).toHaveBeenCalledWith(expect.stringMatching(/completed removal for brand: roo/i));
// Should not exit with error
expect(mockExit).not.toHaveBeenCalledWith(1);
});
});