diff --git a/tests/unit/services/group-sync.test.ts b/tests/unit/services/group-sync.test.ts index ad145eb..20fb62f 100644 --- a/tests/unit/services/group-sync.test.ts +++ b/tests/unit/services/group-sync.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, beforeEach, mock, spyOn } from 'bun:test'; -import { GroupSyncService } from '../../src/services/group-sync'; -import { db } from '../../src/db'; -import { env } from '../../src/env'; +import { GroupSyncService } from '../../../src/services/group-sync'; +import { db } from '../../../src/db'; +import { env } from '../../../src/env'; // Mock the environment variables const originalEnv = { ...env }; @@ -13,16 +13,14 @@ const mockEnv = { }; // Mock fetch -const mockFetch = mock.global('fetch', () => { - return Promise.resolve({ - ok: true, - json: () => Promise.resolve([ - { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, - { id: 'group2', subject: 'Group 2', linkedParent: 'other-community' }, - { id: 'group3', subject: 'Group 3' } // No linkedParent - ]) - }); -}); +const mockFetch = mock.global('fetch', async () => ({ + ok: true, + json: async () => [ + { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, + { id: 'group2', subject: 'Group 2', linkedParent: 'other-community' }, + { id: 'group3', subject: 'Group 3' } // No linkedParent + ] +})); describe('GroupSyncService', () => { beforeEach(() => { @@ -33,6 +31,7 @@ describe('GroupSyncService', () => { afterAll(() => { Object.assign(env, originalEnv); + mockFetch.mockRestore(); }); describe('syncGroups', () => {