Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1009 B
Raw Blame
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderHook } from "@testing-library/react";
import { useGroupSigningState } from "@editor/hooks/useGroupSigningEnabled";

vi.mock("@editor/contexts/AppConfigContext", () => ({
  useAppConfig: () => ({
    config: { storageGroupSigningEnabled: true },
    loading: false,
  }),
}));
const authState = vi.hoisted(() => ({ isAnonymous: false }));
vi.mock("@editor/auth/UseSession", () => ({ useAuth: () => authState }));

describe("useGroupSigningState", () => {
  beforeEach(() => {
    authState.isAnonymous = false;
  });

  it("follows the server config for an account", () => {
    const { result } = renderHook(() => useGroupSigningState());
    expect(result.current).toEqual({ enabled: true, settled: true });
  });

  it("is off for a guest", () => {
    authState.isAnonymous = true;
    const { result } = renderHook(() => useGroupSigningState());
    expect(result.current).toEqual({ enabled: false, settled: true });
  });
});