import { assert, describe } from "@effect/vitest";
import { createOxlintRuleHarness } from "../test/utils.ts";
const rule = createOxlintRuleHarness("t3code/no-native-title-tooltip", {
filename: "fixture.tsx",
});
describe("t3code/no-native-title-tooltip", () => {
rule.valid(
"allows intrinsic elements without a title attribute",
`const el = Truncated text;`,
);
rule.valid(
"allows title props on custom components",
`const el = ;`,
);
rule.valid(
"allows title on member expression components",
`const el = ;`,
);
rule.valid(
"allows title as an accessible name on embedded content",
`const el = ;`,
);
rule.valid("allows the svg title child element", `const el = ;`);
rule.valid("allows document.title assignments", `document.title = "Thread ยท T3 Code";`);
rule.invalid(
"reports title on a truncating span",
`const el = Repo;`,
(output) => {
assert.match(output, /native title attribute/);
},
);
rule.invalid(
"reports title on a button",
`const el = ;`,
(output) => {
assert.match(output, /Tooltip \+ TooltipTrigger \+ TooltipPopup/);
},
);
rule.invalid(
"reports title on a paragraph",
`const el =
src/main.ts
;`,
);
rule.invalid(
"reports title on a code element",
`const el = abc;`,
);
rule.invalid("reports title on an anchor", `const el = More;`);
});