75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import Footer from "./Footer";
|
|
|
|
describe("Footer contact and navigation", () => {
|
|
it("offers project contact and a direct mailto link", () => {
|
|
render(<Footer />);
|
|
|
|
expect(
|
|
screen.getByRole("link", { name: "Conversar sobre meu projeto" }),
|
|
).toHaveAttribute("href", "/#contact");
|
|
|
|
const emailLink = screen.getByRole("link", {
|
|
name: "[email protected]",
|
|
});
|
|
expect(emailLink).toHaveAttribute(
|
|
"href",
|
|
"mailto:[email protected]",
|
|
);
|
|
expect(emailLink).not.toHaveAttribute("target", "_blank");
|
|
});
|
|
|
|
it("renders quick links as same-tab navigation", () => {
|
|
render(<Footer />);
|
|
|
|
const servicesLink = screen.getByRole("link", { name: "Hub de serviços" });
|
|
expect(servicesLink).toHaveAttribute("href", "/servicos");
|
|
expect(servicesLink).not.toHaveAttribute("target", "_blank");
|
|
expect(screen.getByRole("link", { name: "Privacidade" })).toHaveAttribute(
|
|
"href",
|
|
"/privacidade",
|
|
);
|
|
});
|
|
|
|
it("keeps the résumé page and PDF download as the final secondary links", () => {
|
|
render(<Footer />);
|
|
|
|
const résuméLink = screen.getByRole("link", { name: "Currículo" });
|
|
const downloadLink = screen.getByRole("link", {
|
|
name: "Baixar currículo (PDF)",
|
|
});
|
|
expect(résuméLink).toHaveAttribute("href", "/curriculo");
|
|
expect(downloadLink).toHaveAttribute("href", "/Profile.pdf");
|
|
expect(downloadLink).toHaveAttribute(
|
|
"download",
|
|
"Evandro_Fonseca_Junior_CV.pdf",
|
|
);
|
|
expect(screen.getAllByRole("link").slice(-2)).toEqual([
|
|
résuméLink,
|
|
downloadLink,
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("Footer social links", () => {
|
|
it("opens social links securely in a new tab", () => {
|
|
render(<Footer />);
|
|
|
|
const socialLinks = screen.getAllByRole("link", { name: /profile/i });
|
|
|
|
for (const link of socialLinks) {
|
|
expect(link).toHaveAttribute("target", "_blank");
|
|
expect(link).toHaveAttribute("rel", "noopener noreferrer");
|
|
expect(link.querySelector("svg")).toHaveAttribute("aria-hidden", "true");
|
|
}
|
|
|
|
expect(screen.getByLabelText("Visit GitHub profile")).toHaveAttribute(
|
|
"href",
|
|
"https://github.com/evandrodevbr",
|
|
);
|
|
expect(
|
|
screen.getByLabelText("Visit LinkedIn profile").getAttribute("href"),
|
|
).toContain("https://www.linkedin.com/in/evandrodevbr/");
|
|
});
|
|
});
|