import { render, screen } from "@solidjs/testing-library";
import { describe, expect, it } from "vitest";
import { Link } from "../../../src/components/link/index";

describe("Link", () => {
	it("renders as anchor with role=link", () => {
		render(() => <Link href="/page">Go</Link>);
		expect(screen.getByRole("link")).toBeTruthy();
	});
	it("has href attribute", () => {
		render(() => <Link href="/page">Go</Link>);
		expect(screen.getByRole("link").getAttribute("href")).toBe("/page");
	});
	it("disabled link has aria-disabled", () => {
		render(() => (
			<Link href="/page" disabled>
				Go
			</Link>
		));
		expect(screen.getByRole("link").getAttribute("aria-disabled")).toBe("true");
	});
	it("disabled link prevents navigation", () => {
		render(() => (
			<Link href="/page" disabled>
				Go
			</Link>
		));
		expect(screen.getByRole("link").getAttribute("href")).toBeNull();
	});
});
