test: cover error model and unauth order create
This commit is contained in:
@@ -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: "请先登录" },
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user