"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const queue_repo_1 = require("./queue-repo");
describe("idempotent", () => {
    it("only executes once per key", async () => {
        const log = [];
        const logOnce = (0, queue_repo_1.idempotent)(async (line) => {
            log.push(line);
        });
        await logOnce("1");
        await logOnce("1");
        await logOnce("2");
        expect(log).toEqual(["1", "2"]);
    });
    it("throws errors", async () => {
        const thrower = (0, queue_repo_1.idempotent)(async () => {
            throw new Error("error");
        });
        await expect(thrower()).rejects.toThrowError("error");
        await expect(thrower()).rejects.toThrowError("error");
    });
});
//# sourceMappingURL=queue-repo.spec.js.map