feat(user): sync entitlement snapshot
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { toView } from "@/stores/user/user-machine.helpers";
|
||||
import {
|
||||
applyEntitlementSnapshotToView,
|
||||
toView,
|
||||
} from "@/stores/user/user-machine.helpers";
|
||||
|
||||
describe("toView", () => {
|
||||
it("fills optional user fields with stable defaults", () => {
|
||||
@@ -11,6 +14,8 @@ describe("toView", () => {
|
||||
avatarUrl: "",
|
||||
intimacy: 0,
|
||||
dolBalance: 0,
|
||||
creditBalance: 0,
|
||||
vipExpiresAt: null,
|
||||
relationshipStage: "",
|
||||
currentMood: "",
|
||||
isGuest: false,
|
||||
@@ -28,6 +33,8 @@ describe("toView", () => {
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
creditBalance: 120,
|
||||
vipExpiresAt: "2026-07-26T00:00:00+00:00",
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
@@ -41,6 +48,8 @@ describe("toView", () => {
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
creditBalance: 120,
|
||||
vipExpiresAt: "2026-07-26T00:00:00+00:00",
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
@@ -48,4 +57,19 @@ describe("toView", () => {
|
||||
voiceMinutesRemaining: 30,
|
||||
});
|
||||
});
|
||||
|
||||
it("merges entitlement snapshot into user view fields", () => {
|
||||
const user = toView({ id: "user-3", username: "Nora", isVip: false });
|
||||
|
||||
expect(
|
||||
applyEntitlementSnapshotToView(user, {
|
||||
isVip: true,
|
||||
creditBalance: 120,
|
||||
}),
|
||||
).toMatchObject({
|
||||
isVip: true,
|
||||
creditBalance: 120,
|
||||
dolBalance: 120,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user