|
|
@@ -0,0 +1,401 @@
|
|
|
+/**
|
|
|
+ * G-250-1 覆盖缺口闭环:家庭工作台 6 个内嵌面板的行为断言
|
|
|
+ * ================================================================
|
|
|
+ * 背景:`ChildrenPanel / PointsPanel / WishesPanel / RewardsPanel / FamilyCouponPanel /
|
|
|
+ * FamilyEarningsPanel` 共 1,775 行,此前仅有 `FamilyWorkbench.spec.js` 一条「挂载 + familyId
|
|
|
+ * 透传」用例,CRUD / 分页 / 校验 / 空态 / 错误态 0 断言(假绿风险)。
|
|
|
+ *
|
|
|
+ * 本文件按「家庭级 tab 面板」的真实契约补行为用例,断言重点是:
|
|
|
+ * 1. familyId 锁定:面板必须把父组件注入的 familyId 传给后端(不得回退 localStorage);
|
|
|
+ * 2. 空态:接口返回空集时列表为空且不抛错;
|
|
|
+ * 3. 错误态:接口失败时给出用户可见提示,不产生未捕获异常;
|
|
|
+ * 4. 写操作:定价 / 发放 / 审批等动作携带正确参数,且成功后刷新列表;
|
|
|
+ * 5. 前置校验:非法输入必须在调用后端之前被拦住(不发请求)。
|
|
|
+ *
|
|
|
+ * 只读约定:全部走 jest.mock,不发真实请求、不写任何数据。
|
|
|
+ */
|
|
|
+import { shallowMount } from "@vue/test-utils"
|
|
|
+
|
|
|
+import ChildrenPanel from "@/views/admin/ChildrenPanel.vue"
|
|
|
+import PointsPanel from "@/views/admin/PointsPanel.vue"
|
|
|
+import WishesPanel from "@/views/admin/WishesPanel.vue"
|
|
|
+import RewardsPanel from "@/views/admin/RewardsPanel.vue"
|
|
|
+import FamilyCouponPanel from "@/views/admin/FamilyCouponPanel.vue"
|
|
|
+import FamilyEarningsPanel from "@/views/admin/FamilyEarningsPanel.vue"
|
|
|
+
|
|
|
+import {
|
|
|
+ getChildrenList,
|
|
|
+ adjustChildPoints,
|
|
|
+ updateChild,
|
|
|
+ getPointsLogs,
|
|
|
+ getWishesList,
|
|
|
+ getPendingWishes,
|
|
|
+ setWishPrice,
|
|
|
+ getRewardsList,
|
|
|
+ getRewardTemplates,
|
|
|
+ approveReward,
|
|
|
+ getFamilyEarningsList,
|
|
|
+ getFamilyEarningsDetail
|
|
|
+} from "@/api/admin"
|
|
|
+import {
|
|
|
+ getCouponList,
|
|
|
+ issueFamilyCoupon,
|
|
|
+ getFamilyCoupons,
|
|
|
+ getFamilyCouponUsage
|
|
|
+} from "@/api/coupon"
|
|
|
+
|
|
|
+jest.mock("@/api/admin")
|
|
|
+jest.mock("@/api/coupon")
|
|
|
+
|
|
|
+const flush = async (wrapper) => {
|
|
|
+ await wrapper.vm.$nextTick()
|
|
|
+ await Promise.resolve()
|
|
|
+ await wrapper.vm.$nextTick()
|
|
|
+}
|
|
|
+
|
|
|
+function mountPanel(Comp, propsData) {
|
|
|
+ const $message = { error: jest.fn(), success: jest.fn(), warning: jest.fn() }
|
|
|
+ const wrapper = shallowMount(Comp, {
|
|
|
+ propsData: propsData || { familyId: 5 },
|
|
|
+ mocks: {
|
|
|
+ $message,
|
|
|
+ $confirm: jest.fn(() => Promise.resolve()),
|
|
|
+ $route: { params: { id: "5" } },
|
|
|
+ $router: { push: jest.fn() }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return { wrapper, $message }
|
|
|
+}
|
|
|
+
|
|
|
+beforeEach(() => {
|
|
|
+ jest.clearAllMocks()
|
|
|
+})
|
|
|
+
|
|
|
+describe("ChildrenPanel(家庭工作台 · 孩子 tab)", () => {
|
|
|
+ it("挂载即按锁定 familyId + 默认分页拉取,records 落入表格", async () => {
|
|
|
+ getChildrenList.mockResolvedValue({ data: { records: [{ id: 1, nickname: "小明" }], total: 1 } })
|
|
|
+ const { wrapper } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getChildrenList).toHaveBeenCalledTimes(1)
|
|
|
+ expect(getChildrenList.mock.calls[0][0]).toEqual({ page: 1, size: 10, nickname: "", familyId: 5 })
|
|
|
+ expect(wrapper.vm.tableData).toHaveLength(1)
|
|
|
+ expect(wrapper.vm.pagination.total).toBe(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("空集不报错且 total 归零(空态)", async () => {
|
|
|
+ getChildrenList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper, $message } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(wrapper.vm.tableData).toEqual([])
|
|
|
+ expect(wrapper.vm.pagination.total).toBe(0)
|
|
|
+ expect($message.error).not.toHaveBeenCalled()
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("接口失败给出可见错误且 loading 归位(错误态)", async () => {
|
|
|
+ getChildrenList.mockRejectedValue(new Error("后端 500"))
|
|
|
+ const { wrapper, $message } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect($message.error).toHaveBeenCalledWith("后端 500")
|
|
|
+ expect(wrapper.vm.loading).toBe(false)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("切换每页条数重置到第 1 页", async () => {
|
|
|
+ getChildrenList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.pagination.current = 3
|
|
|
+ wrapper.vm.handleSizeChange(20)
|
|
|
+ await flush(wrapper)
|
|
|
+ const last = getChildrenList.mock.calls[getChildrenList.mock.calls.length - 1][0]
|
|
|
+ expect(last.page).toBe(1)
|
|
|
+ expect(last.size).toBe(20)
|
|
|
+ expect(last.familyId).toBe(5)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("调整积分携带孩子 id 与表单值并在成功后刷新", async () => {
|
|
|
+ getChildrenList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ adjustChildPoints.mockResolvedValue({ data: true })
|
|
|
+ const { wrapper, $message } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.$refs.pointsForm = { validate: (cb) => cb(true) }
|
|
|
+ wrapper.vm.currentChild = { id: 9 }
|
|
|
+ wrapper.vm.pointsForm = { amount: 5, reason: "表现好" }
|
|
|
+ await wrapper.vm.submitPoints()
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(adjustChildPoints).toHaveBeenCalledWith(9, { amount: 5, reason: "表现好" })
|
|
|
+ expect($message.success).toHaveBeenCalled()
|
|
|
+ expect(getChildrenList).toHaveBeenCalledTimes(2)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("编辑资料携带 id 并调用 updateChild", async () => {
|
|
|
+ getChildrenList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ updateChild.mockResolvedValue({ data: true })
|
|
|
+ const { wrapper } = mountPanel(ChildrenPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.$refs.editForm = { validate: (cb) => cb(true) }
|
|
|
+ wrapper.vm.editForm = { id: 3, nickname: "小红", age: 8, penaltyEnabled: 1 }
|
|
|
+ await wrapper.vm.submitEdit()
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(updateChild).toHaveBeenCalledWith(3, { id: 3, nickname: "小红", age: 8, penaltyEnabled: 1 })
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+describe("PointsPanel(家庭工作台 · 积分 tab)", () => {
|
|
|
+ it("挂载按 familyId 拉取积分流水并回填 total", async () => {
|
|
|
+ getPointsLogs.mockResolvedValue({ data: { records: [{ id: 1 }], total: 42 } })
|
|
|
+ const { wrapper } = mountPanel(PointsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getPointsLogs.mock.calls[0][0]).toEqual({ page: 1, size: 10, familyId: 5 })
|
|
|
+ expect(wrapper.vm.list).toHaveLength(1)
|
|
|
+ expect(wrapper.vm.total).toBe(42)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("流水类型映射:已知类型出中文,未知类型回显原值,空出占位", () => {
|
|
|
+ getPointsLogs.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(PointsPanel)
|
|
|
+ expect(wrapper.vm.typeLabel("task")).toBe("任务奖励")
|
|
|
+ expect(wrapper.vm.typeLabel("exchange")).toBe("兑换扣除")
|
|
|
+ expect(wrapper.vm.typeLabel("unknown-type")).toBe("unknown-type")
|
|
|
+ expect(wrapper.vm.typeLabel("")).toBe("—")
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("孩子关键字非数字时不提交 memberId(前置校验,避免把 NaN 发给后端)", async () => {
|
|
|
+ getPointsLogs.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(PointsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.filter.childKeyword = "abc"
|
|
|
+ wrapper.vm.handleSearch()
|
|
|
+ await flush(wrapper)
|
|
|
+ let params = getPointsLogs.mock.calls[getPointsLogs.mock.calls.length - 1][0]
|
|
|
+ expect(params.memberId).toBeUndefined()
|
|
|
+ wrapper.vm.filter.childKeyword = "12"
|
|
|
+ wrapper.vm.handleSearch()
|
|
|
+ await flush(wrapper)
|
|
|
+ params = getPointsLogs.mock.calls[getPointsLogs.mock.calls.length - 1][0]
|
|
|
+ expect(params.memberId).toBe(12)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("查看详情打开抽屉并锁定当前行", async () => {
|
|
|
+ getPointsLogs.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(PointsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.handleDetail({ id: 77, description: "任务奖励" })
|
|
|
+ expect(wrapper.vm.detailVisible).toBe(true)
|
|
|
+ expect(wrapper.vm.currentRow.id).toBe(77)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+describe("WishesPanel(家庭工作台 · 心愿 tab)", () => {
|
|
|
+ it("挂载用锁定 familyId 拉待处理心愿,并按状态分组计数", async () => {
|
|
|
+ getPendingWishes.mockResolvedValue({
|
|
|
+ data: [
|
|
|
+ { id: 1, status: "draft" },
|
|
|
+ { id: 2, status: "draft" },
|
|
|
+ { id: 3, status: "pending_exchange" },
|
|
|
+ { id: 4, status: "approved" },
|
|
|
+ { id: 5, status: "exchanging" }
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ const { wrapper } = mountPanel(WishesPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getPendingWishes).toHaveBeenCalledWith(5)
|
|
|
+ expect(wrapper.vm.draftCount).toBe(2)
|
|
|
+ expect(wrapper.vm.pendingCount).toBe(1)
|
|
|
+ expect(wrapper.vm.approvedCount).toBe(1)
|
|
|
+ expect(wrapper.vm.exchangingCount).toBe(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("familyId 缺失时不发请求(面板必须由父组件锁定家庭)", async () => {
|
|
|
+ const { wrapper } = mountPanel(WishesPanel, { familyId: null })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getPendingWishes).not.toHaveBeenCalled()
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("定价非法积分被前置拦截,合法积分携带 id + 数值", async () => {
|
|
|
+ getPendingWishes.mockResolvedValue({ data: [] })
|
|
|
+ const { wrapper, $message } = mountPanel(WishesPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.currentWish = { id: 20, title: "乐高" }
|
|
|
+ wrapper.vm.priceValue = 0
|
|
|
+ await wrapper.vm.submitPrice()
|
|
|
+ expect($message.warning).toHaveBeenCalled()
|
|
|
+ expect(setWishPrice).not.toHaveBeenCalled()
|
|
|
+
|
|
|
+ setWishPrice.mockResolvedValue({ data: true })
|
|
|
+ wrapper.vm.priceValue = 260
|
|
|
+ await wrapper.vm.submitPrice()
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(setWishPrice).toHaveBeenCalledWith(20, 260)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("打开定价弹窗时回填已有积分,缺省 100", async () => {
|
|
|
+ getPendingWishes.mockResolvedValue({ data: [] })
|
|
|
+ const { wrapper } = mountPanel(WishesPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.handleActionCmd({ id: 1, pointsRequired: 320 }, "price")
|
|
|
+ expect(wrapper.vm.priceValue).toBe(320)
|
|
|
+ expect(wrapper.vm.priceDialogVisible).toBe(true)
|
|
|
+ wrapper.vm.handleActionCmd({ id: 2 }, "price")
|
|
|
+ expect(wrapper.vm.priceValue).toBe(100)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("切到「全部」tab 才加载全量列表,且带 familyId", async () => {
|
|
|
+ getPendingWishes.mockResolvedValue({ data: [] })
|
|
|
+ getWishesList.mockResolvedValue({ data: { records: [{ id: 1 }], total: 1 } })
|
|
|
+ const { wrapper } = mountPanel(WishesPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getWishesList).not.toHaveBeenCalled()
|
|
|
+ wrapper.vm.handleTabClick({ name: "all" })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getWishesList.mock.calls[0][0].familyId).toBe(5)
|
|
|
+ expect(wrapper.vm.tableData).toHaveLength(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+describe("RewardsPanel(家庭工作台 · 奖励 tab)", () => {
|
|
|
+ it("挂载按 familyId 拉奖励列表", async () => {
|
|
|
+ getRewardsList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(RewardsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getRewardsList.mock.calls[0][0]).toEqual({ page: 1, size: 10, status: "", familyId: 5 })
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("模板 tab 惰性加载且只加载一次", async () => {
|
|
|
+ getRewardsList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ getRewardTemplates.mockResolvedValue({ data: [{ id: 1, title: "模板A" }] })
|
|
|
+ const { wrapper } = mountPanel(RewardsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ wrapper.vm.handleTabClick({ name: "templates" })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getRewardTemplates).toHaveBeenCalledTimes(1)
|
|
|
+ expect(wrapper.vm.templates).toHaveLength(1)
|
|
|
+ wrapper.vm.handleTabClick({ name: "templates" })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getRewardTemplates).toHaveBeenCalledTimes(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("审批通过携带 {approved:true} 并在成功后刷新", async () => {
|
|
|
+ getRewardsList.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ approveReward.mockResolvedValue({ data: true })
|
|
|
+ const { wrapper, $message } = mountPanel(RewardsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ await wrapper.vm.handleApprove({ id: 8, title: "兑换乐高" }, true)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(approveReward).toHaveBeenCalledWith(8, { approved: true })
|
|
|
+ expect($message.success).toHaveBeenCalled()
|
|
|
+ expect(getRewardsList).toHaveBeenCalledTimes(2)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+describe("FamilyCouponPanel(家庭工作台 · 优惠券 tab)", () => {
|
|
|
+ it("挂载同时拉券池与家庭券,familyId 锁定", async () => {
|
|
|
+ getCouponList.mockResolvedValue({ data: { records: [{ id: 1 }] } })
|
|
|
+ getFamilyCoupons.mockResolvedValue({ data: { records: [{ id: 9 }], total: 1 } })
|
|
|
+ const { wrapper } = mountPanel(FamilyCouponPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getCouponList).toHaveBeenCalled()
|
|
|
+ expect(getFamilyCoupons.mock.calls[0][0]).toEqual({
|
|
|
+ familyId: 5,
|
|
|
+ status: undefined,
|
|
|
+ page: 1,
|
|
|
+ size: 20
|
|
|
+ })
|
|
|
+ expect(wrapper.vm.listData).toHaveLength(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("familyId 缺失时家庭券接口不被调用(防越权跨家庭)", async () => {
|
|
|
+ getCouponList.mockResolvedValue({ data: { records: [] } })
|
|
|
+ const { wrapper } = mountPanel(FamilyCouponPanel, { familyId: null })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getFamilyCoupons).not.toHaveBeenCalled()
|
|
|
+ expect(getFamilyCouponUsage).not.toHaveBeenCalled()
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("未选券时发放被前置拦截;选定后参数完整", async () => {
|
|
|
+ getCouponList.mockResolvedValue({ data: { records: [] } })
|
|
|
+ getFamilyCoupons.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ issueFamilyCoupon.mockResolvedValue({ data: true })
|
|
|
+ const { wrapper, $message } = mountPanel(FamilyCouponPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ await wrapper.vm.confirmIssue()
|
|
|
+ expect($message.warning).toHaveBeenCalled()
|
|
|
+ expect(issueFamilyCoupon).not.toHaveBeenCalled()
|
|
|
+
|
|
|
+ wrapper.vm.issueForm = { couponId: 7, quantity: 2 }
|
|
|
+ await wrapper.vm.confirmIssue()
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(issueFamilyCoupon).toHaveBeenCalledWith({ familyId: 5, couponId: 7, quantity: 2 })
|
|
|
+ expect(wrapper.vm.issueForm.couponId).toBe(null)
|
|
|
+ expect(wrapper.vm.issueForm.quantity).toBe(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("券面文案按类型区分折扣券与满减券", () => {
|
|
|
+ getCouponList.mockResolvedValue({ data: { records: [] } })
|
|
|
+ getFamilyCoupons.mockResolvedValue({ data: { records: [], total: 0 } })
|
|
|
+ const { wrapper } = mountPanel(FamilyCouponPanel)
|
|
|
+ expect(wrapper.vm.couponLabel({ type: "DISCOUNT", name: "8.5折券", discountRate: 850 })).toBe(
|
|
|
+ "8.5折券(8.5折)"
|
|
|
+ )
|
|
|
+ expect(wrapper.vm.couponLabel({ type: "CASH", name: "满减券", value: 1500 })).toBe(
|
|
|
+ "满减券(15.00元)"
|
|
|
+ )
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+describe("FamilyEarningsPanel(家庭工作台 · 收益 tab)", () => {
|
|
|
+ it("挂载按 familyId 拉收益列表", async () => {
|
|
|
+ getFamilyEarningsList.mockResolvedValue({ data: [{ id: 1, amount: 100 }] })
|
|
|
+ const { wrapper } = mountPanel(FamilyEarningsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getFamilyEarningsList.mock.calls[0][0]).toEqual({ familyId: 5 })
|
|
|
+ expect(wrapper.vm.list).toHaveLength(1)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("分转元:正常值两位小数,空值与非法值归零", () => {
|
|
|
+ getFamilyEarningsList.mockResolvedValue({ data: [] })
|
|
|
+ const { wrapper } = mountPanel(FamilyEarningsPanel)
|
|
|
+ expect(wrapper.vm.fenToYuan(1234)).toBe("12.34")
|
|
|
+ expect(wrapper.vm.fenToYuan(0)).toBe("0.00")
|
|
|
+ expect(wrapper.vm.fenToYuan(null)).toBe("0.00")
|
|
|
+ expect(wrapper.vm.fenToYuan(undefined)).toBe("0.00")
|
|
|
+ expect(wrapper.vm.fenToYuan("abc")).toBe("0.00")
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+
|
|
|
+ it("详情接口失败时回退到行数据且提示错误(降级不白屏)", async () => {
|
|
|
+ getFamilyEarningsList.mockResolvedValue({ data: [] })
|
|
|
+ getFamilyEarningsDetail.mockRejectedValue(new Error("boom"))
|
|
|
+ const { wrapper, $message } = mountPanel(FamilyEarningsPanel)
|
|
|
+ await flush(wrapper)
|
|
|
+ await wrapper.vm.showDetail({ id: 3, familyId: 5, amount: 999 })
|
|
|
+ await flush(wrapper)
|
|
|
+ expect(getFamilyEarningsDetail).toHaveBeenCalledWith(5)
|
|
|
+ expect(wrapper.vm.detail.id).toBe(3)
|
|
|
+ expect($message.error).toHaveBeenCalledWith("加载详情失败")
|
|
|
+ expect(wrapper.vm.detailLoading).toBe(false)
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|