test(chat): add test for defaulting nullable credit fields to zero

This commit is contained in:
2026-06-30 19:33:34 +08:00
parent a105820b88
commit b7bccaa4cf
2 changed files with 30 additions and 5 deletions
@@ -1,6 +1,6 @@
import { z } from "zod";
import { stringOrEmpty } from "../nullable-defaults";
import { numberOrZero, stringOrEmpty } from "../nullable-defaults";
import { ChatLockDetailSchema } from "./chat_payloads";
/**
@@ -12,10 +12,10 @@ export const UnlockPrivateResponseSchema = z.object({
unlocked: z.boolean(),
content: stringOrEmpty,
reason: UnlockPrivateReasonSchema,
creditBalance: z.number().default(0),
creditsCharged: z.number().default(0),
requiredCredits: z.number().default(0),
shortfallCredits: z.number().default(0),
creditBalance: numberOrZero,
creditsCharged: numberOrZero,
requiredCredits: numberOrZero,
shortfallCredits: numberOrZero,
lockDetail: ChatLockDetailSchema,
});