#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
import { describe, it, expect, vi, beforeEach } from "vitest";
import { renderHook } from "@testing-library/react";
import { useSharingEnabled } from "@editor/hooks/useSharingEnabled";
vi.mock("@editor/contexts/AppConfigContext", () => ({
useAppConfig: () => ({
config: { storageSharingEnabled: true, storageShareLinksEnabled: true },
}),
}));
const authState = vi.hoisted(() => ({ isAnonymous: false }));
vi.mock("@editor/auth/UseSession", () => ({ useAuth: () => authState }));
describe("useSharingEnabled", () => {
beforeEach(() => {
authState.isAnonymous = false;
});
it("follows the server config for an account", () => {
const { result } = renderHook(() => useSharingEnabled());
expect(result.current).toEqual({
sharingEnabled: true,
shareLinksEnabled: true,
});
});
it("is off for a guest", () => {
authState.isAnonymous = true;
const { result } = renderHook(() => useSharingEnabled());
expect(result.current).toEqual({
sharingEnabled: false,
shareLinksEnabled: false,
});
});
});