Files
BortStack/react/src/components/Footer/Footer.test.jsx
T

24 lines
1.5 KiB
React

import { render, screen, within } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, it } from "vitest";
import Footer from "./Footer";
describe("Footer", () => {
it("presents the business and public navigation without developer attribution", () => {
render(<MemoryRouter><Footer /></MemoryRouter>);
const footer = screen.getByRole("contentinfo");
expect(within(footer).getByText(`© ${new Date().getFullYear()} BortStack`)).toBeVisible();
expect(within(footer).getByText("Navigation", { exact: true })).toBeVisible();
const navigation = within(footer).getByRole("navigation", { name: "Footer navigation" });
expect(within(navigation).getByRole("link", { name: "Contact" })).toHaveAttribute("href", "/contact");
expect(within(footer).getByRole("link", { name: "Privacy" })).toHaveAttribute("href", "/privacy");
for (const [name, href] of [["Services", "/services"], ["Projects", "/projects"], ["About", "/about"]]) {
expect(within(navigation).getByRole("link", { name })).toHaveAttribute("href", href);
}
expect(within(footer).getByText("Software, websites and integrations built around your business.")).toBeVisible();
expect(within(footer).getAllByRole("link")).toHaveLength(5);
expect(footer).not.toHaveTextContent(/roborto/i);
expect(within(footer).queryByRole("img")).not.toBeInTheDocument();
});
});