feat: unify income payment cards and remove comparisons (WealthLedger/main#33) (#74)
feat: unify income payment cards and remove comparisons (WealthLedger/main#33)
This commit was merged in pull request #74.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user