#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 type { ReactNode } from "react";
import { cleanup, render, screen } from "@testing-library/react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { StartupSetup } from "@editor/components/startup/StartupSetup";
const h = vi.hoisted(() => ({
saas: false,
appVersion: undefined as string | undefined,
setup: vi.fn(),
}));
vi.mock("@editor/hooks/useSaaSMode", () => ({ useSaaSMode: () => h.saas }));
vi.mock("@editor/contexts/AppConfigContext", () => ({
useAppConfig: () => ({ config: { appVersion: h.appVersion } }),
}));
vi.mock("@editor-core/components/startup/StartupSetup", () => ({
StartupSetup: (props: { children: ReactNode }) => {
h.setup();
return <>{props.children}</>;
},
}));
beforeEach(() => {
h.saas = false;
h.appVersion = undefined;
h.setup.mockClear();
});
afterEach(cleanup);
it("waits for desktop config readiness", () => {
const view = render(<StartupSetup>Consent</StartupSetup>);
expect(h.setup).not.toHaveBeenCalled();
h.appVersion = "1.0";
view.rerender(<StartupSetup>Consent</StartupSetup>);
expect(h.setup).toHaveBeenCalled();
});
it("leaves hosted account setup to the identity provider", () => {
h.saas = true;
h.appVersion = "1.0";
render(<StartupSetup>Consent</StartupSetup>);
expect(screen.getByText("Consent")).toBeVisible();
expect(h.setup).not.toHaveBeenCalled();
});