UNPKG

popsicle-retry

Version:
35 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const node_1 = require("servie/dist/node"); const index_1 = require("./index"); describe("popsicle retry", () => { const req = new node_1.Request("/"); const done = () => { throw new TypeError("Unhandled request"); }; it("should succeed", async () => { const transport = async (_) => new node_1.Response(null, { status: 200 }); const send = index_1.retry(transport); const res = await send(req, done); expect(res.status).toEqual(200); }); it("should succeed after retry", async () => { let i = 0; const transport = async (_) => { return new node_1.Response(null, { status: ++i === 2 ? 200 : 500 }); }; const send = index_1.retry(transport); const res = await send(req, done); expect(res.status).toEqual(200); }); it("should fail after max retries", async () => { jest.setTimeout(10000); const transport = async (_) => { return new node_1.Response(null, { status: 500 }); }; const send = index_1.retry(transport); const res = await send(req, done); expect(res.status).toEqual(500); }); }); //# sourceMappingURL=index.spec.js.map