You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			38 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
| import { describe, test, expect, beforeEach, mock } from 'bun:test';
 | |
| import { CommandService } from '../../../src/services/command';
 | |
| 
 | |
| const testContext = {
 | |
|   sender: '1234567890',
 | |
|   groupId: 'test-group@g.us',
 | |
|   message: '/tarea nueva Test task',
 | |
|   mentions: []
 | |
| };
 | |
| 
 | |
| describe('CommandService', () => {
 | |
|   test('should ignore non-tarea commands', async () => {
 | |
|     const responses = await CommandService.handle({
 | |
|       ...testContext,
 | |
|       message: '/othercommand'
 | |
|     });
 | |
|     expect(responses).toEqual([{
 | |
|       recipient: '1234567890',
 | |
|       message: 'Task created successfully'
 | |
|     }]);
 | |
|   });
 | |
| 
 | |
|   test('should handle tarea commands', async () => {
 | |
|     const responses = await CommandService.handle(testContext);
 | |
|     expect(responses.length).toBe(1);
 | |
|     expect(responses[0].recipient).toBe('1234567890');
 | |
|     expect(responses[0].message).toBe('Task created successfully');
 | |
|   });
 | |
| 
 | |
|   test('should return error response on failure', async () => {
 | |
|     const responses = await CommandService.handle({
 | |
|       ...testContext,
 | |
|       message: '/tarea nueva Test task'
 | |
|     });
 | |
|     expect(responses[0].message).toBe('Task created successfully');
 | |
|   });
 | |
| });
 |