import { describe, it, expect, vi, beforeEach } from "vitest"; import { render, waitFor } from "@testing-library/react"; import React from "react"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { updateStatusWhenErrorMessagePresent, WsClientProvider, useWsClient, } from "#/context/ws-client-provider"; describe("Propagate error message", () => { it("should do nothing when no message was passed from server", () => { updateStatusWhenErrorMessagePresent(null); updateStatusWhenErrorMessagePresent(undefined); updateStatusWhenErrorMessagePresent({}); updateStatusWhenErrorMessagePresent({ message: null }); }); it.todo("should display error to user when present"); it.todo("should display error including translation id when present"); }); // Create a mock for socket.io-client const mockEmit = vi.fn(); const mockOn = vi.fn(); const mockOff = vi.fn(); const mockDisconnect = vi.fn(); vi.mock("socket.io-client", () => ({ io: vi.fn(() => ({ emit: mockEmit, on: mockOn, off: mockOff, disconnect: mockDisconnect, io: { opts: { query: {}, }, }, })), })); // Mock component to test the hook function TestComponent() { const { send } = useWsClient(); React.useEffect(() => { // Send a test event send({ type: "test_event" }); }, [send]); return