Update soul-content project
This commit is contained in:
1
app/components/PaymentTest.js
Normal file
1
app/components/PaymentTest.js
Normal file
@@ -0,0 +1 @@
|
||||
import React from 'react';\nimport { Button } from '@/components/ui/button';\nimport { paymentService } from '../services/paymentService';\n\nexport function PaymentTest() {\n const handleTestPayment = async () => {\n try {\n const order = { amount: 9.9, currency: 'CNY' };\n const result = await paymentService.pay(order);\n console.log('Payment result:', result);\n } catch (error) {\n console.error('Payment error:', error);\n }\n };\n\n return (\n <div>\n <Button onClick={handleTestPayment}>测试支付</Button>\n </div>\n );\n}\n
|
||||
1
app/components/__tests__/PaymentTest.test.js
Normal file
1
app/components/__tests__/PaymentTest.test.js
Normal file
@@ -0,0 +1 @@
|
||||
import { render, fireEvent } from '@testing-library/react';\nimport { PaymentTest } from '../PaymentTest';\n\ndescribe('PaymentTest Component', () => {\n it('renders without crashing', () => {\n const { getByText } = render(<PaymentTest />);\n expect(getByText('测试支付')).toBeInTheDocument();\n });\n\n it('calls handleTestPayment on button click', () => {\n const consoleSpy = jest.spyOn(console, 'log').mockImplementation(() => {});\n const { getByText } = render(<PaymentTest />);\n fireEvent.click(getByText('测试支付'));\n expect(consoleSpy).toHaveBeenCalledWith('Payment result:', expect.anything());\n consoleSpy.mockRestore();\n });\n});\n
|
||||
Reference in New Issue
Block a user