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