52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { type BcPageData, BcPageDetail } from "./bc-manager";
|
|
|
|
vi.mock("@/actions/catalog-bc", () => ({
|
|
createBcItem: vi.fn(),
|
|
deleteBcItem: vi.fn(),
|
|
updateBcItem: vi.fn(),
|
|
updateBcPage: vi.fn(),
|
|
}));
|
|
vi.mock("@/components/admin/confirm-dialog", () => ({
|
|
useConfirmDialog: () => ({ confirm: vi.fn(), dialog: null }),
|
|
}));
|
|
vi.mock("@/hooks/use-server-action", () => ({
|
|
useServerAction: () => ({ isPending: false, run: vi.fn() }),
|
|
}));
|
|
|
|
const page: BcPageData = {
|
|
id: 7,
|
|
parentId: -1,
|
|
caption: "Builder Club",
|
|
pageLayout: "default_3x3",
|
|
iconColor: 0,
|
|
iconImage: 1,
|
|
orderNum: 1,
|
|
visible: "1",
|
|
enabled: "1",
|
|
pageHeadline: "",
|
|
pageTeaser: "",
|
|
pageSpecial: "",
|
|
pageText1: "",
|
|
pageText2: "",
|
|
pageTextDetails: "",
|
|
pageTextTeaser: "",
|
|
};
|
|
|
|
describe("BcPageDetail", () => {
|
|
it("uses the canonical return route when embedded in Housekeeping", () => {
|
|
const markup = renderToStaticMarkup(
|
|
<BcPageDetail
|
|
page={page}
|
|
items={[]}
|
|
canEdit={false}
|
|
returnHref="/ase/economy/catalog"
|
|
/>,
|
|
);
|
|
|
|
expect(markup).toContain('href="/ase/economy/catalog"');
|
|
expect(markup).not.toContain('href="/admin/catalog?catalog=bc"');
|
|
});
|
|
});
|