fix: correct test import paths and improve mocks

main
borja (aider) 3 months ago
parent 3be7783aa8
commit 7b9f9f2478

@ -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', () => {

Loading…
Cancel
Save