import { describe, expect, it } from "vitest";
import { GENERIC_LINK_TEXT } from "@banes-lab/web/configuration/constants/link.constants.ts";
import { checkLinkNames } from "@banes-lab/build-scripts/core/validators/element.validator.ts";
const FILE = "index.html";
describe("checkLinkNames", () => {
it("accepts a link named by its text, its aria-label, an image's alt or its title", () => {
const html = `The methodology
`;
expect(checkLinkNames(FILE, html)).toStrictEqual([]);
});
it("reports a link with no discernible name", () => {
const findings = checkLinkNames(FILE, ``);
expect(findings).toHaveLength(1);
expect(findings[0]?.message).toContain("/methodology");
});
it("reports a link whose whole text is a generic phrase, whatever its case and spacing", () => {
expect(checkLinkNames(FILE, ` Start Read More`)).toHaveLength(2);
expect(GENERIC_LINK_TEXT.has("start")).toBe(true);
});
it("accepts a generic word once the link text carries its context", () => {
const html = `Start — Methodology`;
expect(checkLinkNames(FILE, html)).toStrictEqual([]);
});
});