37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import userEvent from "@testing-library/user-event";
|
|
import NoRules from "../../../app/components/cards/NoRules";
|
|
import { renderWithProviders, screen } from "../../utils/test-utils";
|
|
|
|
describe("NoRules", () => {
|
|
it("renders the empty-state copy, create action, and templates link", async () => {
|
|
const user = userEvent.setup();
|
|
const onCreate = vi.fn();
|
|
renderWithProviders(
|
|
<NoRules
|
|
title="No Rules yet"
|
|
description="Start from a template, or write your first over a few short meetings with the free kit."
|
|
createLabel="Create rule"
|
|
browseLabel="Browse templates"
|
|
browseHref="/templates?fromFlow=1"
|
|
onCreate={onCreate}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole("heading", { name: "No Rules yet" })).toBeInTheDocument();
|
|
expect(
|
|
screen.getByText(
|
|
"Start from a template, or write your first over a few short meetings with the free kit.",
|
|
),
|
|
).toBeInTheDocument();
|
|
|
|
await user.click(screen.getByRole("button", { name: "Create rule" }));
|
|
expect(onCreate).toHaveBeenCalledTimes(1);
|
|
|
|
expect(
|
|
screen.getByRole("link", { name: "Browse templates" }),
|
|
).toHaveAttribute("href", "/templates?fromFlow=1");
|
|
});
|
|
});
|