fix: round money to currency minor units without negative zero (WealthLedger/frontend#118) (#119)
This commit was merged in pull request #119.
This commit is contained in:
@@ -56,6 +56,16 @@ describe("shared display helpers", () => {
|
||||
)).toBe("0,00 ₽");
|
||||
});
|
||||
|
||||
it("rounds to the currency's minor units and drops the sign of a rounded zero", () => {
|
||||
const rounded = { withRoundedCents: true };
|
||||
expect(formatMoney({ currency: "RUB", value: "-0.004" }, rounded)).toBe("0,00 ₽");
|
||||
expect(formatMoney({ currency: "RUB", value: "-0.005" }, rounded)).toBe("-0,01 ₽");
|
||||
expect(formatMoney({ currency: "RUB", value: "999.995" }, rounded)).toBe("1 000,00 ₽");
|
||||
expect(formatMoney({ currency: "JPY", value: "1500.5" }, rounded)).toBe("1 501 JPY");
|
||||
expect(formatMoney({ currency: "KWD", value: "1.2345" }, rounded)).toBe("1,235 KWD");
|
||||
expect(formatMoney({ currency: "ZZZ", value: "1.234" }, rounded)).toBe("1,23 ZZZ");
|
||||
});
|
||||
|
||||
it("builds the brand logo url from an upstream file name", () => {
|
||||
expect(instrumentLogoUrl("sber3.png")).toBe(
|
||||
"https://invest-brands.cdn-tinkoff.ru/sber3x160.png",
|
||||
|
||||
Reference in New Issue
Block a user