From ff82f626594038b19d14c42301f09b63417e59a7 Mon Sep 17 00:00:00 2001 From: "borja (aider)" Date: Sat, 29 Mar 2025 23:46:31 +0100 Subject: [PATCH] test: fix group sync test mocks to match API format --- tests/unit/services/group-sync.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/services/group-sync.test.ts b/tests/unit/services/group-sync.test.ts index e69fdcc..defc4d2 100644 --- a/tests/unit/services/group-sync.test.ts +++ b/tests/unit/services/group-sync.test.ts @@ -15,11 +15,14 @@ describe('GroupSyncService', () => { // Setup mock fetch fetchMock = mock(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 - ] + json: async () => ({ + status: 'success', + response: [ + { id: 'group1', subject: 'Group 1', linkedParent: 'test-community' }, + { id: 'group2', subject: 'Group 2', linkedParent: 'other-community' }, + { id: 'group3', subject: 'Group 3' } // No linkedParent + ] + }) })); globalThis.fetch = fetchMock; @@ -86,7 +89,8 @@ describe('GroupSyncService', () => { it('should handle API errors', async () => { globalThis.fetch = mock(async () => ({ ok: false, - statusText: 'Not Found' + statusText: 'Not Found', + json: async () => ({ status: 'error', message: 'Not Found' }) })); await expect(GroupSyncService.syncGroups()).rejects.toThrow('API request failed: Not Found'); });