|
|
|
|
@ -52,22 +52,11 @@ describe('GroupSyncService', () => {
|
|
|
|
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should throw if WHATSAPP_COMMUNITY_ID is missing', async () => {
|
|
|
|
|
const consoleErrorMock = mock(() => {});
|
|
|
|
|
console.error = consoleErrorMock;
|
|
|
|
|
|
|
|
|
|
it('should return empty result if WHATSAPP_COMMUNITY_ID is missing', async () => {
|
|
|
|
|
process.env.WHATSAPP_COMMUNITY_ID = '';
|
|
|
|
|
|
|
|
|
|
await expect(GroupSyncService.syncGroups())
|
|
|
|
|
.rejects.toThrow('WHATSAPP_COMMUNITY_ID is not set');
|
|
|
|
|
|
|
|
|
|
expect(consoleErrorMock).toHaveBeenCalledWith(
|
|
|
|
|
'Group sync failed:',
|
|
|
|
|
expect.any(Error)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Restore original console.error
|
|
|
|
|
console.error = originalConsoleError;
|
|
|
|
|
const result = await GroupSyncService.syncGroups();
|
|
|
|
|
expect(result).toEqual({ added: 0, updated: 0 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should filter groups by community ID', async () => {
|
|
|
|
|
|