test: cover error model and unauth order create

This commit is contained in:
zetaloop
2026-02-28 07:26:34 +08:00
parent 411ee8293d
commit d5f59f9a4a
2 changed files with 51 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { createPaidOrder } from "@/lib/api/orders"
import { useAuthStore } from "@/store/auth"
import { describe, expect, it } from "vitest"
describe("lib/api/orders", () => {
it("returns { decision: { ok:false, error:{code,msg} } } when unauthenticated", () => {
useAuthStore.getState().logout()
const res = createPaidOrder({
playerId: "1005",
serviceId: "5001",
quantity: 1,
})
expect(res).toEqual({
decision: {
ok: false,
error: { code: 401, msg: "请先登录" },
},
})
})
})