refactor: improve mocking for GitHubClient and enhance SIGINT handling in tests
This commit is contained in:
@@ -1573,7 +1573,7 @@ describe("promptForPort", () => {
|
||||
vi.mocked(createInterface).mockReturnValue(mockRl as unknown as ReturnType<typeof createInterface>);
|
||||
|
||||
// Simulate that the promise rejects when SIGINT is triggered
|
||||
const removeListenerSpy = vi.spyOn(process, "removeListener").mockImplementation(() => process as unknown as void);
|
||||
const removeListenerSpy = vi.spyOn(process, "removeListener" as any).mockImplementation(() => process);
|
||||
|
||||
// Trigger SIGINT handler immediately to test rejection
|
||||
let sigintHandler: (() => void) | null = null;
|
||||
|
||||
@@ -2,8 +2,10 @@ import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from "vite
|
||||
import { GitHubRateLimiter, GitHubPollingService, githubPoller, githubRateLimiter } from "../github-poll.js";
|
||||
import type { TaskStore } from "@fusion/core";
|
||||
|
||||
// Mock the GitHubClient
|
||||
const mockGetBadgeStatusesBatch = vi.fn();
|
||||
// Mock the GitHubClient - use vi.hoisted to ensure proper hoisting with vi.mock
|
||||
const { mockGetBadgeStatusesBatch } = vi.hoisted(() => ({
|
||||
mockGetBadgeStatusesBatch: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../github.js", () => ({
|
||||
GitHubClient: vi.fn().mockImplementation(() => ({
|
||||
@@ -128,7 +130,6 @@ describe("GitHubPollingService", () => {
|
||||
service.stop();
|
||||
service.reset();
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe("configure", () => {
|
||||
|
||||
Reference in New Issue
Block a user