feat: redesign portfolio position cards
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { formatMoney } from "./display";
|
||||
import { formatMoney, formatShare } from "./display";
|
||||
|
||||
describe("portfolio display helpers", () => {
|
||||
it("formats decimal strings without financial arithmetic", () => {
|
||||
@@ -10,4 +10,27 @@ describe("portfolio display helpers", () => {
|
||||
expect(formatMoney({ value: "0.5", currency: "USD" })).toBe("0,5 USD");
|
||||
expect(formatMoney(null)).toBe("—");
|
||||
});
|
||||
|
||||
it("formats a share as a display-only percentage", () => {
|
||||
expect(
|
||||
formatShare(
|
||||
{ currency: "RUB", value: "150" },
|
||||
{ currency: "RUB", value: "1000" },
|
||||
),
|
||||
).toBe("15 %");
|
||||
expect(
|
||||
formatShare(
|
||||
{ currency: "RUB", value: "123.45" },
|
||||
{ currency: "RUB", value: "999.99" },
|
||||
),
|
||||
).toBe("12,3 %");
|
||||
expect(formatShare(null, { currency: "RUB", value: "100" })).toBeNull();
|
||||
expect(formatShare({ currency: "RUB", value: "100" }, null)).toBeNull();
|
||||
expect(
|
||||
formatShare(
|
||||
{ currency: "RUB", value: "100" },
|
||||
{ currency: "RUB", value: "0" },
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user