|
| 1 | +import { describe, it, expect } from "vitest"; |
| 2 | +import { render } from "@solidjs/testing-library"; |
| 3 | +import RepoGitHubLink from "../../src/app/components/shared/RepoGitHubLink"; |
| 4 | + |
| 5 | +describe("RepoGitHubLink", () => { |
| 6 | + it("renders issues link with correct href and label", () => { |
| 7 | + const { container } = render(() => ( |
| 8 | + <RepoGitHubLink repoFullName="owner/repo" section="issues" /> |
| 9 | + )); |
| 10 | + const link = container.querySelector("a")!; |
| 11 | + expect(link.getAttribute("href")).toBe("https://github.com/owner/repo/issues"); |
| 12 | + expect(link.getAttribute("aria-label")).toBe("Open owner/repo issues on GitHub"); |
| 13 | + expect(link.getAttribute("target")).toBe("_blank"); |
| 14 | + expect(link.getAttribute("rel")).toBe("noopener noreferrer"); |
| 15 | + }); |
| 16 | + |
| 17 | + it("renders pulls link with correct href and label", () => { |
| 18 | + const { container } = render(() => ( |
| 19 | + <RepoGitHubLink repoFullName="owner/repo" section="pulls" /> |
| 20 | + )); |
| 21 | + const link = container.querySelector("a")!; |
| 22 | + expect(link.getAttribute("href")).toBe("https://github.com/owner/repo/pulls"); |
| 23 | + expect(link.getAttribute("aria-label")).toBe("Open owner/repo pull requests on GitHub"); |
| 24 | + }); |
| 25 | + |
| 26 | + it("renders actions link with correct href and label", () => { |
| 27 | + const { container } = render(() => ( |
| 28 | + <RepoGitHubLink repoFullName="owner/repo" section="actions" /> |
| 29 | + )); |
| 30 | + const link = container.querySelector("a")!; |
| 31 | + expect(link.getAttribute("href")).toBe("https://github.com/owner/repo/actions"); |
| 32 | + expect(link.getAttribute("aria-label")).toBe("Open owner/repo actions on GitHub"); |
| 33 | + }); |
| 34 | + |
| 35 | + it("renders ExternalLinkIcon SVG with aria-hidden", () => { |
| 36 | + const { container } = render(() => ( |
| 37 | + <RepoGitHubLink repoFullName="owner/repo" section="issues" /> |
| 38 | + )); |
| 39 | + const svg = container.querySelector("svg"); |
| 40 | + expect(svg).not.toBeNull(); |
| 41 | + expect(svg!.getAttribute("aria-hidden")).toBe("true"); |
| 42 | + }); |
| 43 | +}); |
0 commit comments