This commit is contained in:
Arunavo Ray
2025-07-27 20:19:47 +05:30
parent de314cf174
commit 5d5429ac71

View File

@@ -38,17 +38,27 @@ import { repoStatusEnum } from "@/types/Repository";
describe("Enhanced Gitea Operations", () => { describe("Enhanced Gitea Operations", () => {
let originalFetch: typeof global.fetch; let originalFetch: typeof global.fetch;
let originalTimeout: typeof global.setTimeout;
beforeEach(() => { beforeEach(() => {
originalFetch = global.fetch; originalFetch = global.fetch;
originalTimeout = global.setTimeout;
// Clear mocks // Clear mocks
mockCreateMirrorJob.mockClear(); mockCreateMirrorJob.mockClear();
mockDb.insert.mockClear(); mockDb.insert.mockClear();
mockDb.update.mockClear(); mockDb.update.mockClear();
// Mock setTimeout for consistent timing in tests
global.setTimeout = ((fn: Function, delay: number) => {
// Execute immediately in tests to avoid timing issues
fn();
return 0;
}) as any;
}); });
afterEach(() => { afterEach(() => {
global.fetch = originalFetch; global.fetch = originalFetch;
global.setTimeout = originalTimeout;
}); });
describe("getGiteaRepoInfo", () => { describe("getGiteaRepoInfo", () => {