import React from "react";
import { render, screen } from "@sproutsocial/seeds-react-testing-library";
import Link from "../Link";
describe("Link Tailwind path", () => {
it("renders with the seeds-link class when no styled props are used", () => {
render(Tailwind Link);
const el = screen.getByText("Tailwind Link");
expect(el.tagName).toBe("A");
expect(el).toHaveClass("seeds-link");
});
it("renders a type=button with the no-href class when href is omitted", () => {
render(Button Link);
const el = screen.getByText("Button Link");
expect(el.tagName).toBe("BUTTON");
expect(el).toHaveAttribute("type", "button");
expect(el).toHaveClass("seeds-link");
expect(el).toHaveClass("seeds-link-no-href");
});
it("does not apply the no-href class to anchors", () => {
render(Anchor Link);
const el = screen.getByText("Anchor Link");
expect(el.tagName).toBe("A");
expect(el).toHaveClass("seeds-link");
expect(el).not.toHaveClass("seeds-link-no-href");
});
it("applies the disabled class when disabled", () => {
render(Disabled);
expect(screen.getByText("Disabled")).toHaveClass("seeds-link-disabled");
});
it("forwards a consumer className (styled() extension passthrough)", () => {
render(
Class Link
);
const el = screen.getByText("Class Link");
expect(el).toHaveClass("seeds-link");
expect(el).toHaveClass("sc-extension");
});
it("routes typography props (fontSize) to the styled-components path", () => {
render(
Sized Link
);
expect(screen.getByText("Sized Link")).not.toHaveClass("seeds-link");
});
it("routes fontFamily to the styled-components path", () => {
render(
Mono Link
);
expect(screen.getByText("Mono Link")).not.toHaveClass("seeds-link");
});
it("routes fontStyle to the styled-components path", () => {
render(
Italic Link
);
expect(screen.getByText("Italic Link")).not.toHaveClass("seeds-link");
});
});