|  |  |  | @ -2,8 +2,9 @@ import { describe, it, expect, beforeEach, mock, spyOn } from 'bun:test'; | 
		
	
		
			
				|  |  |  |  | import { GroupSyncService } from '../../../src/services/group-sync'; | 
		
	
		
			
				|  |  |  |  | import { db } from '../../../src/db'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // Mock process.env for testing
 | 
		
	
		
			
				|  |  |  |  | // Store original globals
 | 
		
	
		
			
				|  |  |  |  | const originalEnv = { ...process.env }; | 
		
	
		
			
				|  |  |  |  | const originalFetch = globalThis.fetch; | 
		
	
		
			
				|  |  |  |  | process.env = { | 
		
	
		
			
				|  |  |  |  |   WHATSAPP_COMMUNITY_ID: 'test-community', | 
		
	
		
			
				|  |  |  |  |   EVOLUTION_API_URL: 'http://test-api', | 
		
	
	
		
			
				
					|  |  |  | @ -13,7 +14,7 @@ process.env = { | 
		
	
		
			
				|  |  |  |  | }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // Mock fetch
 | 
		
	
		
			
				|  |  |  |  | const mockFetch = mock.global('fetch', async () => ({ | 
		
	
		
			
				|  |  |  |  | const fetchMock = mock(async () => ({ | 
		
	
		
			
				|  |  |  |  |   ok: true, | 
		
	
		
			
				|  |  |  |  |   json: async () => [ | 
		
	
		
			
				|  |  |  |  |     { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, | 
		
	
	
		
			
				
					|  |  |  | @ -22,6 +23,9 @@ const mockFetch = mock.global('fetch', async () => ({ | 
		
	
		
			
				|  |  |  |  |   ] | 
		
	
		
			
				|  |  |  |  | })); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | // Replace global fetch
 | 
		
	
		
			
				|  |  |  |  | globalThis.fetch = fetchMock; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | describe('GroupSyncService', () => { | 
		
	
		
			
				|  |  |  |  |   beforeEach(() => { | 
		
	
		
			
				|  |  |  |  |     db.exec('DELETE FROM groups'); | 
		
	
	
		
			
				
					|  |  |  | @ -31,7 +35,7 @@ describe('GroupSyncService', () => { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   afterAll(() => { | 
		
	
		
			
				|  |  |  |  |     process.env = originalEnv; | 
		
	
		
			
				|  |  |  |  |     mockFetch.mockRestore(); | 
		
	
		
			
				|  |  |  |  |     globalThis.fetch = originalFetch; | 
		
	
		
			
				|  |  |  |  |   }); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   describe('syncGroups', () => { | 
		
	
	
		
			
				
					|  |  |  | 
 |