feat(shared): add signed percent and percentage-point formatters (WealthLedger/main#54)
This commit is contained in:
@@ -3,12 +3,22 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
formatDate,
|
||||
formatMoney,
|
||||
formatPercentagePoints,
|
||||
formatSignedPercent,
|
||||
formatSnapshotDay,
|
||||
formatSnapshotTime,
|
||||
instrumentLogoUrl,
|
||||
} from "./display";
|
||||
|
||||
describe("shared display helpers", () => {
|
||||
it("formats signed rates as percentages and percentage points without negative zero", () => {
|
||||
expect(formatSignedPercent("0.151")).toBe("+15,1 %");
|
||||
expect(formatSignedPercent("-0.15149")).toBe("−15,1 %");
|
||||
expect(formatSignedPercent("0")).toBe("0,0 %");
|
||||
expect(formatSignedPercent("-0.00049")).toBe("0,0 %");
|
||||
expect(formatPercentagePoints("0.043")).toBe("+4,3 п.п.");
|
||||
expect(formatPercentagePoints("-0.0435")).toBe("−4,4 п.п.");
|
||||
});
|
||||
it("uses padded Russian dates and preserves the UTC date of timestamps", () => {
|
||||
expect(formatDate("2027-09-10")).toBe("10.09.2027");
|
||||
expect(formatDate("2024-02-29")).toBe("29.02.2024");
|
||||
|
||||
Reference in New Issue
Block a user