7e5a851d9c
- analytics.test.ts: add vi to vitest import (was used at lines 24, 37, 66) - BookingError.test.tsx: use regex matchers so phone/email assertions match partial text in combined <p> element Co-Authored-By: Paperclip <noreply@paperclip.ing>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { BookingErrorPage } from "../pages/BookingError.tsx";
|
|
import { BUSINESS_CONTACT_INFO } from "../lib/contact.ts";
|
|
|
|
describe("BookingErrorPage", () => {
|
|
it("renders the error heading", () => {
|
|
render(<BookingErrorPage />);
|
|
expect(screen.getByRole("heading", { name: /Link Invalid or Expired/i })).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders the error body text", () => {
|
|
render(<BookingErrorPage />);
|
|
expect(screen.getByText(/This confirmation link is invalid/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("has a Start a new booking link pointing to /admin/book", () => {
|
|
render(<BookingErrorPage />);
|
|
const link = screen.getByRole("link", { name: /Start a new booking/i });
|
|
expect(link).toHaveAttribute("href", "/admin/book");
|
|
});
|
|
|
|
it("has a Back to Portal link pointing to /", () => {
|
|
render(<BookingErrorPage />);
|
|
const link = screen.getByRole("link", { name: /Back to Portal/i });
|
|
expect(link).toHaveAttribute("href", "/");
|
|
});
|
|
|
|
it("displays business contact phone", () => {
|
|
render(<BookingErrorPage />);
|
|
expect(screen.getByText(new RegExp(BUSINESS_CONTACT_INFO.phone.replace(/[()]/g, "\\$&")))).toBeInTheDocument();
|
|
});
|
|
|
|
it("displays business contact email", () => {
|
|
render(<BookingErrorPage />);
|
|
expect(screen.getByText(new RegExp(BUSINESS_CONTACT_INFO.email))).toBeInTheDocument();
|
|
});
|
|
});
|