53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { AuthBackground } from "../auth-background";
|
|
import { AuthErrorMessage } from "../auth-error-message";
|
|
import { EmailLoginForm } from "../email-login-form";
|
|
import { EmailRegisterForm } from "../email-register-form";
|
|
|
|
vi.mock("@/stores/auth/auth-context", () => ({
|
|
useAuthDispatch: () => vi.fn(),
|
|
}));
|
|
|
|
describe("auth Tailwind components", () => {
|
|
it("renders AuthErrorMessage only when a message is present", () => {
|
|
expect(renderToStaticMarkup(<AuthErrorMessage message={null} />)).toBe("");
|
|
|
|
const html = renderToStaticMarkup(<AuthErrorMessage message="Invalid email" />);
|
|
expect(html).toContain('role="alert"');
|
|
expect(html).toContain("text-error");
|
|
expect(html).toContain("Invalid email");
|
|
});
|
|
|
|
it("renders EmailLoginForm with Tailwind form layout", () => {
|
|
const html = renderToStaticMarkup(<EmailLoginForm />);
|
|
|
|
expect(html).toContain("<form");
|
|
expect(html).toContain("flex");
|
|
expect(html).toContain("w-full");
|
|
expect(html).toContain("gap-md");
|
|
expect(html).toContain("Login");
|
|
});
|
|
|
|
it("renders EmailRegisterForm with Tailwind form layout", () => {
|
|
const html = renderToStaticMarkup(<EmailRegisterForm />);
|
|
|
|
expect(html).toContain("<form");
|
|
expect(html).toContain("flex");
|
|
expect(html).toContain("w-full");
|
|
expect(html).toContain("gap-md");
|
|
expect(html).toContain("Register");
|
|
});
|
|
|
|
it("renders AuthBackground with Tailwind layout classes", () => {
|
|
const html = renderToStaticMarkup(<AuthBackground />);
|
|
|
|
expect(html).toContain("absolute");
|
|
expect(html).toContain("inset-0");
|
|
expect(html).toContain("bg-[#fbf1f2]");
|
|
expect(html).toContain("object-cover");
|
|
expect(html).toContain("%2Fimages%2Fauth%2Fbg-login.png");
|
|
});
|
|
});
|