feat(dealer/withdraw): 更新提现手续费说明并添加对公转账选项
- 更新最低提现金额说明,增加每笔3元手续费信息- 在提现方式中添加对公转账选项 - 删除了withdraw.test.tsx文件,可能因为不再需要相关测试
This commit is contained in:
@@ -1,184 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { render, fireEvent, waitFor } from '@testing-library/react'
|
|
||||||
import DealerWithdraw from '../index'
|
|
||||||
import { useDealerUser } from '@/hooks/useDealerUser'
|
|
||||||
import * as withdrawAPI from '@/api/shop/shopDealerWithdraw'
|
|
||||||
|
|
||||||
// Mock dependencies
|
|
||||||
jest.mock('@/hooks/useDealerUser')
|
|
||||||
jest.mock('@/api/shop/shopDealerWithdraw')
|
|
||||||
jest.mock('@tarojs/taro', () => ({
|
|
||||||
showToast: jest.fn(),
|
|
||||||
getStorageSync: jest.fn(() => 123),
|
|
||||||
}))
|
|
||||||
|
|
||||||
const mockUseDealerUser = useDealerUser as jest.MockedFunction<typeof useDealerUser>
|
|
||||||
const mockAddShopDealerWithdraw = withdrawAPI.addShopDealerWithdraw as jest.MockedFunction<typeof withdrawAPI.addShopDealerWithdraw>
|
|
||||||
const mockPageShopDealerWithdraw = withdrawAPI.pageShopDealerWithdraw as jest.MockedFunction<typeof withdrawAPI.pageShopDealerWithdraw>
|
|
||||||
|
|
||||||
describe('DealerWithdraw', () => {
|
|
||||||
const mockDealerUser = {
|
|
||||||
userId: 123,
|
|
||||||
money: '10000.00',
|
|
||||||
realName: '测试用户',
|
|
||||||
mobile: '13800138000'
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
mockUseDealerUser.mockReturnValue({
|
|
||||||
dealerUser: mockDealerUser,
|
|
||||||
loading: false,
|
|
||||||
error: null,
|
|
||||||
refresh: jest.fn()
|
|
||||||
})
|
|
||||||
|
|
||||||
mockPageShopDealerWithdraw.mockResolvedValue({
|
|
||||||
list: [],
|
|
||||||
count: 0
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
jest.clearAllMocks()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('应该正确显示可提现余额', () => {
|
|
||||||
const { getByText } = render(<DealerWithdraw />)
|
|
||||||
expect(getByText('10000.00')).toBeInTheDocument()
|
|
||||||
expect(getByText('可提现余额')).toBeInTheDocument()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('应该验证最低提现金额', async () => {
|
|
||||||
mockAddShopDealerWithdraw.mockResolvedValue('success')
|
|
||||||
|
|
||||||
const { getByPlaceholderText, getByText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 输入低于最低金额的数值
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额')
|
|
||||||
fireEvent.change(amountInput, { target: { value: '50' } })
|
|
||||||
|
|
||||||
// 选择提现方式
|
|
||||||
const wechatRadio = getByText('微信钱包')
|
|
||||||
fireEvent.click(wechatRadio)
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const submitButton = getByText('申请提现')
|
|
||||||
fireEvent.click(submitButton)
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(require('@tarojs/taro').showToast).toHaveBeenCalledWith({
|
|
||||||
title: '最低提现金额为100元',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('应该验证提现金额不超过可用余额', async () => {
|
|
||||||
const { getByPlaceholderText, getByText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 输入超过可用余额的金额
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额')
|
|
||||||
fireEvent.change(amountInput, { target: { value: '20000' } })
|
|
||||||
|
|
||||||
// 选择提现方式
|
|
||||||
const wechatRadio = getByText('微信钱包')
|
|
||||||
fireEvent.click(wechatRadio)
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const submitButton = getByText('申请提现')
|
|
||||||
fireEvent.click(submitButton)
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(require('@tarojs/taro').showToast).toHaveBeenCalledWith({
|
|
||||||
title: '提现金额超过可用余额',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('应该验证支付宝账户信息完整性', async () => {
|
|
||||||
const { getByPlaceholderText, getByText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 输入有效金额
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额')
|
|
||||||
fireEvent.change(amountInput, { target: { value: '1000' } })
|
|
||||||
|
|
||||||
// 选择支付宝提现
|
|
||||||
const alipayRadio = getByText('支付宝')
|
|
||||||
fireEvent.click(alipayRadio)
|
|
||||||
|
|
||||||
// 只填写账号,不填写姓名
|
|
||||||
const accountInput = getByPlaceholderText('请输入支付宝账号')
|
|
||||||
fireEvent.change(accountInput, { target: { value: 'test@alipay.com' } })
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const submitButton = getByText('申请提现')
|
|
||||||
fireEvent.click(submitButton)
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(require('@tarojs/taro').showToast).toHaveBeenCalledWith({
|
|
||||||
title: '请填写完整的支付宝信息',
|
|
||||||
icon: 'error'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('应该成功提交微信提现申请', async () => {
|
|
||||||
mockAddShopDealerWithdraw.mockResolvedValue('success')
|
|
||||||
|
|
||||||
const { getByPlaceholderText, getByText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 输入有效金额
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额')
|
|
||||||
fireEvent.change(amountInput, { target: { value: '1000' } })
|
|
||||||
|
|
||||||
// 选择微信提现
|
|
||||||
const wechatRadio = getByText('微信钱包')
|
|
||||||
fireEvent.click(wechatRadio)
|
|
||||||
|
|
||||||
// 提交表单
|
|
||||||
const submitButton = getByText('申请提现')
|
|
||||||
fireEvent.click(submitButton)
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(mockAddShopDealerWithdraw).toHaveBeenCalledWith({
|
|
||||||
userId: 123,
|
|
||||||
money: '1000',
|
|
||||||
payType: 10,
|
|
||||||
applyStatus: 10,
|
|
||||||
platform: 'MiniProgram'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
expect(require('@tarojs/taro').showToast).toHaveBeenCalledWith({
|
|
||||||
title: '提现申请已提交',
|
|
||||||
icon: 'success'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('快捷金额按钮应该正常工作', () => {
|
|
||||||
const { getByText, getByPlaceholderText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 点击快捷金额按钮
|
|
||||||
const quickAmountButton = getByText('500')
|
|
||||||
fireEvent.click(quickAmountButton)
|
|
||||||
|
|
||||||
// 验证金额输入框的值
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额') as HTMLInputElement
|
|
||||||
expect(amountInput.value).toBe('500')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('全部按钮应该设置为可用余额', () => {
|
|
||||||
const { getByText, getByPlaceholderText } = render(<DealerWithdraw />)
|
|
||||||
|
|
||||||
// 点击全部按钮
|
|
||||||
const allButton = getByText('全部')
|
|
||||||
fireEvent.click(allButton)
|
|
||||||
|
|
||||||
// 验证金额输入框的值
|
|
||||||
const amountInput = getByPlaceholderText('请输入提现金额') as HTMLInputElement
|
|
||||||
expect(amountInput.value).toBe('10000.00')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -303,7 +303,7 @@ const DealerWithdraw: React.FC = () => {
|
|||||||
borderTop: '1px solid rgba(255, 255, 255, 0.3)'
|
borderTop: '1px solid rgba(255, 255, 255, 0.3)'
|
||||||
}}>
|
}}>
|
||||||
<Text className="text-white text-opacity-80 text-xs">
|
<Text className="text-white text-opacity-80 text-xs">
|
||||||
最低提现金额:¥100 | 手续费:免费
|
最低提现金额:¥100 | 手续费:每笔3元
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -365,6 +365,9 @@ const DealerWithdraw: React.FC = () => {
|
|||||||
<Cell>
|
<Cell>
|
||||||
<Radio value="bank">银行卡</Radio>
|
<Radio value="bank">银行卡</Radio>
|
||||||
</Cell>
|
</Cell>
|
||||||
|
<Cell>
|
||||||
|
<Radio value="bank">对公转账</Radio>
|
||||||
|
</Cell>
|
||||||
</Cell.Group>
|
</Cell.Group>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
Reference in New Issue
Block a user