import { describe, test, expect, mock } from 'bun:test'; import { CommandService } from '../../../src/services/command'; describe('CommandService', () => { const testContext = { sender: '1234567890@s.whatsapp.net', groupId: 'group-id@g.us', message: '/tarea nueva Test task @user1 2025-12-31', mentions: ['user1@s.whatsapp.net'], createdBy: '1234567890@s.whatsapp.net' // Added to match new interface }; test('should ignore non-tarea commands', async () => { const responses = await CommandService.handle({ ...testContext, message: '/othercommand' }); expect(responses).toEqual([]); }); test('should handle tarea commands', async () => { const responses = await CommandService.handle(testContext); expect(responses.length).toBe(1); expect(responses[0].recipient).toBe(testContext.sender); expect(responses[0].message).toInclude('Command received'); }); test('should return error response on failure', async () => { const originalProcess = CommandService.processTareaCommand; CommandService.processTareaCommand = mock(() => { throw new Error('Test error'); }); const responses = await CommandService.handle(testContext); expect(responses[0].message).toInclude('Error processing'); CommandService.processTareaCommand = originalProcess; }); });