|
|
|
@ -15,11 +15,14 @@ describe('GroupSyncService', () => {
|
|
|
|
|
// Setup mock fetch
|
|
|
|
|
fetchMock = mock(async () => ({
|
|
|
|
|
ok: true,
|
|
|
|
|
json: async () => [
|
|
|
|
|
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');
|
|
|
|
|
});
|
|
|
|
|