Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Successful in 5m10s
Conventional commits / commits (pull_request) Successful in 25s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Successful in 5m10s
87 lines
2.8 KiB
TypeScript
87 lines
2.8 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 { brokerageAccountCards } from "../../model/display";
|
|
import { BrokerageAccountList } from "./BrokerageAccountList";
|
|
|
|
describe("BrokerageAccountList", () => {
|
|
it("renders account details and an account link", () => {
|
|
render(
|
|
<MantineProvider>
|
|
<MemoryRouter>
|
|
<BrokerageAccountList
|
|
accounts={brokerageAccountCards([
|
|
{
|
|
id: "account-1",
|
|
name: "Основной",
|
|
type: "BROKERAGE",
|
|
openedOn: "2024-08-13",
|
|
portfolioSummary: {
|
|
stockPositionCount: 5,
|
|
bondPositionCount: 12,
|
|
totalsByCurrency: [
|
|
{ currency: "RUB", value: "1500" },
|
|
{ currency: "USD", value: "20" },
|
|
{ currency: "EUR", value: "5" },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
id: "account-2",
|
|
name: "Недоступный",
|
|
type: "BROKERAGE",
|
|
openedOn: null,
|
|
portfolioSummary: null,
|
|
},
|
|
{
|
|
id: "account-3",
|
|
name: "Пустой",
|
|
type: "BROKERAGE",
|
|
openedOn: null,
|
|
portfolioSummary: {
|
|
totalsByCurrency: [],
|
|
stockPositionCount: 2,
|
|
bondPositionCount: 0,
|
|
},
|
|
},
|
|
])}
|
|
/>
|
|
</MemoryRouter>
|
|
</MantineProvider>,
|
|
);
|
|
|
|
expect(screen.getByRole("link", { name: /Основной/ })).toHaveAttribute(
|
|
"href",
|
|
"/accounts/account-1",
|
|
);
|
|
expect(screen.getAllByText("Брокерский счет")).toHaveLength(3);
|
|
expect(screen.getByText(/^Открыт /)).toBeInTheDocument();
|
|
expect(screen.getByText("1 500 ₽")).toBeInTheDocument();
|
|
expect(screen.getByText("20 USD")).toBeInTheDocument();
|
|
expect(screen.getByText("Еще 1 валюта")).toBeInTheDocument();
|
|
expect(screen.getByText("Сводка временно недоступна")).toBeInTheDocument();
|
|
expect(screen.getByText("Нет текущих сумм")).toBeInTheDocument();
|
|
expect(screen.getAllByText("Открыть счет")).toHaveLength(3);
|
|
const available = within(screen.getByRole("link", { name: /Основной/ }));
|
|
expect(available.getByText("Акции").nextElementSibling).toHaveTextContent(
|
|
"5",
|
|
);
|
|
expect(
|
|
available.getByText("Облигации").nextElementSibling,
|
|
).toHaveTextContent("12");
|
|
const unvalued = within(screen.getByRole("link", { name: /Пустой/ }));
|
|
expect(unvalued.getByText("Акции").nextElementSibling).toHaveTextContent(
|
|
"2",
|
|
);
|
|
expect(
|
|
unvalued.getByText("Облигации").nextElementSibling,
|
|
).toHaveTextContent("0");
|
|
expect(
|
|
within(screen.getByRole("link", { name: /Недоступный/ })).queryByText(
|
|
"Акции",
|
|
),
|
|
).not.toBeInTheDocument();
|
|
});
|
|
});
|