fix(user): align dto with latest payload

This commit is contained in:
2026-06-25 17:40:41 +08:00
parent e01b0daaf3
commit 94fb3ed19b
4 changed files with 50 additions and 24 deletions
+45
View File
@@ -0,0 +1,45 @@
import { describe, expect, it } from "vitest";
import { User } from "@/data/dto/user/user";
describe("User", () => {
it("parses the latest backend user payload", () => {
const user = User.fromJson({
id: "d7bb2b3d-e9c5-474c-85fe-f503048f30dd",
username: "guest_bbc90a38",
email: "device_bbc90a38b996187348f54cf2cb0b789e@guest.local",
platform: "web",
intimacy: 0,
dolBalance: 0,
personalityTraits: {
caring: 0.5,
playful: 0.5,
serious: 0.5,
cheerful: 0.5,
romantic: 0.5,
},
preferredLanguage: "zh",
createdAt: "2026-06-12T08:08:27.378706+00:00",
lastMessageAt: "2026-06-24T11:00:23.156561+00:00",
});
expect(user.toJson()).toEqual({
id: "d7bb2b3d-e9c5-474c-85fe-f503048f30dd",
username: "guest_bbc90a38",
email: "device_bbc90a38b996187348f54cf2cb0b789e@guest.local",
platform: "web",
intimacy: 0,
dolBalance: 0,
personalityTraits: {
caring: 0.5,
playful: 0.5,
serious: 0.5,
cheerful: 0.5,
romantic: 0.5,
},
preferredLanguage: "zh",
createdAt: "2026-06-12T08:08:27.378706+00:00",
lastMessageAt: "2026-06-24T11:00:23.156561+00:00",
});
});
});