fix(subscription): update price formatting to use dot decimal separator

This commit is contained in:
2026-07-01 18:12:03 +08:00
parent 4253da4e4c
commit 0251916a8a
2 changed files with 24 additions and 8 deletions
@@ -62,7 +62,7 @@ describe("subscription screen helpers", () => {
{
id: "coin_1000",
coins: 1000,
price: "9,9",
price: "9.90",
currency: "US$",
},
]);
@@ -76,17 +76,33 @@ describe("subscription screen helpers", () => {
{
id: "vip_monthly",
title: "Monthly",
price: "19,9",
price: "19.90",
currency: "usd",
originalPrice: "",
},
],
coinPlans: [{ id: "coin_1000", coins: 1000, price: "9,9", currency: "US$" }],
coinPlans: [{ id: "coin_1000", coins: 1000, price: "9.90", currency: "US$" }],
});
expect(selected?.id).toBe("coin_1000");
});
it("formats plan amounts from cents with a dot decimal separator", () => {
expect(
toVipOfferPlanViews([
makePlan({
planId: "vip_test",
amountCents: 7790,
}),
]),
).toMatchObject([
{
id: "vip_test",
price: "77.90",
},
]);
});
it("selects the first VIP plan by default when VIP can be purchased", () => {
expect(
getDefaultSubscriptionPlanId({
@@ -99,7 +115,7 @@ describe("subscription screen helpers", () => {
{
id: "vip_monthly",
title: "Monthly",
price: "19,9",
price: "19.90",
currency: "usd",
originalPrice: "",
},
@@ -122,7 +138,7 @@ describe("subscription screen helpers", () => {
{
id: "coin_1000",
coins: 1000,
price: "9,9",
price: "9.90",
currency: "US$",
},
],
@@ -140,7 +156,7 @@ describe("subscription screen helpers", () => {
selectedPlan: {
id: "coin_1000",
coins: 1000,
price: "9,9",
price: "9.90",
currency: "US$",
},
vipPlans: [],
@@ -148,7 +164,7 @@ describe("subscription screen helpers", () => {
{
id: "coin_1000",
coins: 1000,
price: "9,9",
price: "9.90",
currency: "US$",
},
],
@@ -26,7 +26,7 @@ function formatAmount(amountCents: number | null): string | null {
}
function formatOfferAmount(amountCents: number | null): string {
return (formatAmount(amountCents) ?? "").replace(".", ",");
return formatAmount(amountCents) ?? "";
}
function formatOfferCurrency(currency: string): string {