Files
frontend/src/shared/ui/PayoutCard/PayoutCard.test.tsx
T
codex-bot 43b0f5574a
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 10s
Frontend verify / verify (push) Successful in 7m18s
feat: unify income payment cards and remove comparisons (WealthLedger/main#33) (#74)
feat: unify income payment cards and remove comparisons (WealthLedger/main#33)
2026-10-13 18:17:35 +03:00

86 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { FC } from "react";
import { MantineProvider } from "@mantine/core";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { PayoutCard } from "./PayoutCard";
const Wrapper: FC<{ children: React.ReactNode }> = props => (
<MantineProvider env="test">{props.children}</MantineProvider>
);
describe("PayoutCard", () => {
it("renders an executed payout with signed source money", () => {
render(
<Wrapper>
<PayoutCard
initial="К"
kind="executed"
occurredAt="01.08.2026 12:00"
payment={{ currency: "RUB", value: "-10.25" }}
title="Купон"
typeLabel="Купон"
/>
</Wrapper>,
);
expect(screen.getByText("−10,25 ₽")).toBeInTheDocument();
expect(screen.getByText(/Исполнено 01.08.2026 12:00/)).toBeInTheDocument();
});
it("keeps zero distinct from an unknown executed amount", () => {
render(
<Wrapper>
<PayoutCard
initial="Д"
kind="executed"
occurredAt="01.08.2026"
payment={{ currency: "RUB", value: "0.000" }}
title="Дивиденд"
typeLabel="Дивиденд"
/>
</Wrapper>,
);
expect(screen.getByText("0,000 ₽")).toBeInTheDocument();
expect(screen.getByText("Без движения денег")).toBeInTheDocument();
});
it("marks a forecast payout and a dividend registry date without inventing an amount", () => {
render(
<Wrapper>
<PayoutCard
date="15.08.2026"
dateKind="registry"
initial="S"
kind="forecast"
projectedAmount={null}
title="Дивиденд · SBER"
/>
</Wrapper>,
);
expect(screen.getByText("Прогноз")).toBeInTheDocument();
expect(screen.getByText(/15.08.2026 · Дата реестра/)).toBeInTheDocument();
expect(screen.getByText("Сумма неизвестна")).toBeInTheDocument();
});
it("shows a schedule payout with per-security label and separate estimate", () => {
render(
<Wrapper>
<PayoutCard
estimate={{ currency: "RUB", value: "125" }}
initial="S"
kind="schedule"
metadata="Дата выплаты 04.10.2026"
perSecurity={{ currency: "RUB", value: "12.5" }}
perSecurityLabel="На облигацию"
title="Купон · SU26238RMFS4"
/>
</Wrapper>,
);
expect(screen.getByText("12,5 ₽")).toBeInTheDocument();
expect(screen.getByText("На облигацию")).toBeInTheDocument();
expect(screen.getByText("Оценка по позиции")).toBeInTheDocument();
expect(screen.getByText("125 ₽")).toBeInTheDocument();
});
});