#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 { act, renderHook } from "@testing-library/react";
import { expect, it, vi } from "vitest";
import { MemoryRouter } from "react-router-dom";
import type { ReactNode } from "react";
import { LicenseProvider, useLicense } from "@editor/contexts/LicenseContext";
const getLicenseInfo = vi.hoisted(() => vi.fn());
vi.mock("@editor/services/licenseService", () => ({
default: { getLicenseInfo },
}));
vi.mock("@editor/contexts/AppConfigContext", () => ({
useAppConfig: () => ({ config: { isAdmin: true } }),
}));
vi.mock("@editor/testing/serverExperienceSimulations", () => ({
getSimulatedLicenseInfo: () => null,
}));
it("does not read an installation licence on SaaS, including after checkout refresh", async () => {
const { result } = renderHook(() => useLicense(), {
wrapper: ({ children }: { children: ReactNode }) => (
<MemoryRouter>
<LicenseProvider>{children}</LicenseProvider>
</MemoryRouter>
),
});
await act(() => result.current.refetchLicense());
expect(result.current.loading).toBe(false);
expect(result.current.licenseInfo).toBeNull();
expect(getLicenseInfo).not.toHaveBeenCalled();
});