refactor(data): replace schema classes with readonly models

This commit is contained in:
2026-07-17 13:21:40 +08:00
parent 3437312167
commit ae97366a4a
103 changed files with 1220 additions and 2117 deletions
@@ -1,6 +1,10 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { PaymentPlan } from "@/data/schemas/payment";
import {
PaymentPlanSchema,
type PaymentPlan,
type PaymentPlanInput,
} from "@/data/schemas/payment";
import {
canChooseSubscriptionPayChannel,
@@ -13,10 +17,8 @@ import {
toVipOfferPlanViews,
} from "../subscription-screen.helpers";
function makePlan(
overrides: Partial<Parameters<typeof PaymentPlan.from>[0]>,
): PaymentPlan {
return PaymentPlan.from({
function makePlan(overrides: Partial<PaymentPlanInput>): PaymentPlan {
return PaymentPlanSchema.parse({
planId: "plan",
planName: "Plan",
orderType: "vip_monthly",
@@ -138,7 +140,9 @@ describe("subscription screen helpers", () => {
originalPrice: "",
},
],
coinPlans: [{ id: "coin_1000", coins: 1000, price: "9.90", currency: "US$" }],
coinPlans: [
{ id: "coin_1000", coins: 1000, price: "9.90", currency: "US$" },
],
});
expect(selected?.id).toBe("coin_1000");