48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import { MantineProvider } from "@mantine/core";
|
|
import { render, screen, within } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router";
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { AppShell } from "./AppShell";
|
|
|
|
function renderShell(path: string) {
|
|
return render(
|
|
<MantineProvider>
|
|
<MemoryRouter initialEntries={[path]}>
|
|
<AppShell />
|
|
</MemoryRouter>
|
|
</MantineProvider>,
|
|
);
|
|
}
|
|
|
|
describe("AppShell", () => {
|
|
it("has no header banner", () => {
|
|
renderShell("/cards");
|
|
|
|
expect(screen.queryByRole("banner")).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("marks only the current bottom navigation item", () => {
|
|
renderShell("/cards");
|
|
|
|
const bottomNav = screen
|
|
.getAllByRole("navigation", { name: "Основная навигация" })
|
|
.at(-1);
|
|
|
|
if (!bottomNav) {
|
|
throw new Error("Bottom navigation is not rendered");
|
|
}
|
|
|
|
const links = within(bottomNav).getAllByRole("link");
|
|
|
|
expect(links).toHaveLength(5);
|
|
expect(within(bottomNav).getByRole("link", { name: "Карты" })).toHaveAttribute(
|
|
"aria-current",
|
|
"page",
|
|
);
|
|
expect(
|
|
within(bottomNav).getByRole("link", { name: "Счета" }),
|
|
).not.toHaveAttribute("aria-current");
|
|
});
|
|
});
|