"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
const http_1 = __importDefault(require("http"));
const util_1 = require("./util");
test("network unreliable", async () => {
    let callNumber = 0;
    const server = http_1.default
        .createServer((req, res) => {
        callNumber++;
        if (callNumber === 1) {
            // abort connection
            res.socket.end();
        }
        else if (callNumber === 2) {
            res.statusCode = 200;
            res.end();
        }
    })
        .listen(0);
    const quirrel = new __1.QuirrelClient({
        route: "",
        async handler() { },
        config: {
            quirrelBaseUrl: (0, util_1.getAddress)(server),
            applicationBaseUrl: `http://localhost:4000`,
        },
    });
    const response = await quirrel.makeRequest("/");
    expect(response.status).toBe(200);
    expect(callNumber).toBe(2);
    server.close();
});
//# sourceMappingURL=network-unreliable.test.js.map