test(stores): add state machine coverage
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { toView } from "@/stores/user/user-machine.helpers";
|
||||
|
||||
describe("toView", () => {
|
||||
it("fills optional user fields with stable defaults", () => {
|
||||
expect(toView({ id: "user-1", username: "Luna" })).toEqual({
|
||||
id: "user-1",
|
||||
username: "Luna",
|
||||
email: "",
|
||||
avatarUrl: "",
|
||||
intimacy: 0,
|
||||
dolBalance: 0,
|
||||
relationshipStage: "",
|
||||
currentMood: "",
|
||||
isGuest: false,
|
||||
isVip: false,
|
||||
voiceMinutesRemaining: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves provided user fields", () => {
|
||||
expect(
|
||||
toView({
|
||||
id: "user-2",
|
||||
username: "Elio",
|
||||
email: "elio@example.com",
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
isVip: true,
|
||||
voiceMinutesRemaining: 30,
|
||||
}),
|
||||
).toEqual({
|
||||
id: "user-2",
|
||||
username: "Elio",
|
||||
email: "elio@example.com",
|
||||
avatarUrl: "https://example.com/avatar.png",
|
||||
intimacy: 42,
|
||||
dolBalance: 12,
|
||||
relationshipStage: "close_friend",
|
||||
currentMood: "playful",
|
||||
isGuest: true,
|
||||
isVip: true,
|
||||
voiceMinutesRemaining: 30,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user