hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { cleanup, render, screen } from "@solidjs/testing-library"; |
| 2 | import type { JSX } from "solid-js"; |
| 3 | import { afterEach, expect, test, vi } from "vitest"; |
| 4 | import { Breadcrumbs } from "@/components/layout/breadcrumbs"; |
| 5 | import { PreferencesProvider } from "@/stores/preferences-context"; |
| 6 | |
| 7 | vi.mock("@tanstack/solid-router", () => ({ |
| 8 | Link: (props: { to: string; children: JSX.Element; class?: string }) => <a href={props.to} class={props.class}>{props.children}</a>, |
| 9 | })); |
| 10 | |
| 11 | afterEach(cleanup); |
| 12 | |
| 13 | test("links every ancestor and marks the last crumb as the current page", () => { |
| 14 | render(() => ( |
| 15 | <PreferencesProvider> |
| 16 | <Breadcrumbs items={[{ label: "Courses", to: "/courses" }, { label: "Algebra", to: "/courses/$id" }, { label: "9-A" }]} /> |
| 17 | </PreferencesProvider> |
| 18 | )); |
| 19 | |
| 20 | const nav = screen.getByRole("navigation"); |
| 21 | expect(nav.getAttribute("aria-label")).toBeTruthy(); |
| 22 | expect(screen.getAllByRole("link").map((link) => link.getAttribute("href"))).toEqual(["/courses", "/courses/$id"]); |
| 23 | expect(screen.getByText("9-A").getAttribute("aria-current")).toBe("page"); |
| 24 | expect(screen.getByText("Algebra").getAttribute("aria-current")).toBeNull(); |
| 25 | }); |