Files
NapCatQQ/.pnpm-store/v3/files/92/6e33b1e18834ae6af8cf820cdecf7b3f7cd4163df86207954660766ecb6366065261538dd8e851fc3625e0e3ab62bac138ad582409db01fb2bdd3962f8974f
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

30 lines
857 B
Plaintext

import { renderHook, waitFor } from '@testing-library/react';
import { useEventSource } from './use-event-source';
import WS from "jest-websocket-mock";
import { EventSourceOptions } from './types';
import { DEFAULT_EVENT_SOURCE_OPTIONS } from './constants';
let server: WS;
const URL = 'ws://localhost:1234';
const noop = () => {};
const DEFAULT_OPTIONS = DEFAULT_EVENT_SOURCE_OPTIONS;
let options: EventSourceOptions;
console.error = noop;
beforeEach(() => {
server = new WS(URL);
options = { ...DEFAULT_OPTIONS };
});
afterEach(() => {
WS.clean();
});
test('Options#eventSourceOptions, if provided, instantiates an EventSource instead of a WebSocket', async () => {
const {
result
} = renderHook(() => useEventSource(URL, options));
await waitFor(() => expect(result.current.getEventSource() instanceof EventSource).toBe(true));
});