import { describe, expect, it, vi } from 'vitest';
import { INTENTIONAL_CLOSE_CODE, ISocket } from './socket.js';
const PING_TIMEOUT_CLOSE_REASON = 'Ping timeout';
describe('ISocket', () => {
    it('preserves the transport-close marker when rejecting pending requests with a reason', async () => {
        const ws = {
            addEventListener: vi.fn(),
            close: vi.fn(),
            send: vi.fn()
        };
        const socket = new ISocket(ws, {}, [], { onClose: vi.fn() });
        const pendingRequest = socket.request('editor.ping', {});
        socket.closeAndRejectPendingRequests(PING_TIMEOUT_CLOSE_REASON);
        await expect(pendingRequest).rejects.toMatchObject({
            code: 8,
            message: `[internal] Connection closed: ${PING_TIMEOUT_CLOSE_REASON}`
        });
        expect(ws.close).toHaveBeenCalledWith(INTENTIONAL_CLOSE_CODE, PING_TIMEOUT_CLOSE_REASON);
    });
});
//# sourceMappingURL=socket.test.js.map