fix: correct import paths and env mocking in group-sync tests

main
borja (aider) 3 months ago
parent d4869aa178
commit 7cef5448c4

@ -1,22 +1,15 @@
import { describe, it, expect, beforeEach, mock, spyOn } from 'bun:test'; import { describe, it, expect, beforeEach, mock, spyOn } from 'bun:test';
import { GroupSyncService } from '../../src/services/group-sync'; import { GroupSyncService } from '../../../src/services/group-sync';
import { db } from '../../src/db'; import { db } from '../../../src/db';
// Mock environment variables directly since we can't find env.ts // Mock process.env for testing
const env = { const originalEnv = { ...process.env };
WHATSAPP_COMMUNITY_ID: 'test-community', process.env = {
EVOLUTION_API_URL: 'http://test-api',
EVOLUTION_API_INSTANCE: 'test-instance',
EVOLUTION_API_KEY: 'test-key'
};
// Mock the environment variables
const originalEnv = { ...env };
const mockEnv = {
WHATSAPP_COMMUNITY_ID: 'test-community', WHATSAPP_COMMUNITY_ID: 'test-community',
EVOLUTION_API_URL: 'http://test-api', EVOLUTION_API_URL: 'http://test-api',
EVOLUTION_API_INSTANCE: 'test-instance', EVOLUTION_API_INSTANCE: 'test-instance',
EVOLUTION_API_KEY: 'test-key' EVOLUTION_API_KEY: 'test-key',
...process.env
}; };
// Mock fetch // Mock fetch
@ -37,7 +30,7 @@ describe('GroupSyncService', () => {
}); });
afterAll(() => { afterAll(() => {
Object.assign(env, originalEnv); process.env = originalEnv;
mockFetch.mockRestore(); mockFetch.mockRestore();
}); });

Loading…
Cancel
Save