Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

696 B
Raw Blame
// @vitest-environment node

import { describe, expect, test, vi } from "vitest";

vi.mock("./connection", () => ({
  createRedisConnection: () => null,
}));

import { createLockChannel } from "./channel";

describe("createLockChannel", () => {
  test("degrades gracefully when Redis connections are disabled", async () => {
    const lock = createLockChannel("test-lock");

    const token = await lock.acquireAsync(60);

    expect(token).toEqual(expect.any(String));
    if (!token) throw new Error("Expected the fallback lock to return a token");
    await expect(lock.renewAsync(token, 60)).resolves.toBe(true);
    await expect(lock.releaseAsync(token)).resolves.toBeUndefined();
  });
});