Replace the Four Pillars page with the Guide to CommunityRule on the Content page Template.
This commit is contained in:
1 parent
bf9ee79c9f
commit
453139c783
17 files changed
+1005
-32
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { describe, expect, it, vi, beforeEach } from "vitest";
|
||||
import { fireEvent, waitFor } from "@testing-library/react";
|
||||
import {
|
||||
renderWithProviders as render,
|
||||
screen,
|
||||
} from "../utils/test-utils";
|
||||
import HowItWorksShareRow from "../../app/(marketing)/how-it-works/_components/HowItWorksShareRow";
|
||||
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
describe("HowItWorksShareRow", () => {
|
||||
beforeEach(() => {
|
||||
writeText.mockReset();
|
||||
writeText.mockResolvedValue(undefined);
|
||||
Object.defineProperty(window.navigator, "clipboard", {
|
||||
configurable: true,
|
||||
value: { writeText },
|
||||
});
|
||||
});
|
||||
|
||||
it("copies wiki markdown and prints the page", async () => {
|
||||
const print = vi.spyOn(window, "print").mockImplementation(() => {});
|
||||
|
||||
render(
|
||||
<HowItWorksShareRow
|
||||
sendLabel="Send this to your community"
|
||||
copyLabel="Copy into your wiki"
|
||||
printLabel="Print the card"
|
||||
copiedTitle="Copied to clipboard"
|
||||
copyFailedTitle="Could not copy"
|
||||
mailtoHref="mailto:?subject=Guide"
|
||||
wikiMarkdown="[Guide](https://example.com)"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByRole("link", { name: "Send this to your community" }),
|
||||
).toHaveAttribute("href", "mailto:?subject=Guide");
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: "Copy into your wiki" }),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(writeText).toHaveBeenCalledWith("[Guide](https://example.com)");
|
||||
});
|
||||
expect(screen.getByText("Copied to clipboard")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Print the card" }));
|
||||
expect(print).toHaveBeenCalled();
|
||||
print.mockRestore();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user