|
1 | 1 | /** |
2 | | - * Tests for `HeaderNav`'s auth-state-dependent auth control. |
| 2 | + * Tests for `HeaderNav`'s auth-state-dependent auth control and its |
| 3 | + * external-link list. |
3 | 4 | * |
4 | 5 | * `HeaderNav` is tested in isolation against a mocked `useAuth`; the |
5 | 6 | * provider's bootstrap (csrf + me round-trips) is exercised in |
@@ -56,3 +57,40 @@ describe("HeaderNav auth control", () => { |
56 | 57 | expect(mockLogout).toHaveBeenCalledTimes(1); |
57 | 58 | }); |
58 | 59 | }); |
| 60 | + |
| 61 | +describe("HeaderNav structure", () => { |
| 62 | + beforeEach(() => { |
| 63 | + mockAuth = { user: null, loading: false, logout: mockLogout }; |
| 64 | + }); |
| 65 | + |
| 66 | + /** The logo renders and links home (SVG is aria-hidden; the link |
| 67 | + * carries the accessible name). */ |
| 68 | + test("renders the logo linking home", () => { |
| 69 | + render(<HeaderNav />); |
| 70 | + expect( |
| 71 | + screen.getByRole("link", { name: "Civic Tech Jobs - Home" }), |
| 72 | + ).toHaveAttribute("href", "/"); |
| 73 | + }); |
| 74 | +}); |
| 75 | + |
| 76 | +describe("HeaderNav external links", () => { |
| 77 | + beforeEach(() => { |
| 78 | + mockAuth = { user: null, loading: false, logout: mockLogout }; |
| 79 | + }); |
| 80 | + |
| 81 | + /** Only the "Hack for LA" org link remains after the 2026-05-14 trim. */ |
| 82 | + test("renders the Hack for LA link", () => { |
| 83 | + render(<HeaderNav />); |
| 84 | + expect(screen.getByText("Hack for LA").closest("a")).toHaveAttribute( |
| 85 | + "href", |
| 86 | + "https://www.hackforla.org/", |
| 87 | + ); |
| 88 | + }); |
| 89 | + |
| 90 | + /** "How to Join" and "Projects" were dropped; guard against regression. */ |
| 91 | + test("does not render the dropped How to Join / Projects links", () => { |
| 92 | + render(<HeaderNav />); |
| 93 | + expect(screen.queryByText("How to Join")).not.toBeInTheDocument(); |
| 94 | + expect(screen.queryByText("Projects")).not.toBeInTheDocument(); |
| 95 | + }); |
| 96 | +}); |
0 commit comments