import { describe, it, expect, vi, beforeEach } from 'vitest'; import { commerceService } from './commerceService'; describe('commerceService', () => { beforeEach(() => { vi.clearAllMocks(); }); describe('getPurchases', () => { it('should return purchases', async () => { const purchases = await commerceService.getPurchases(); expect(purchases).toBeDefined(); expect(Array.isArray(purchases)).toBe(true); if (purchases.length > 0) { expect(purchases[0]).toHaveProperty('id'); expect(purchases[0]).toHaveProperty('status'); } }); }); describe('getSellerStats', () => { it('should return sales statistics', async () => { const stats = await commerceService.getSellerStats(); expect(stats).toBeDefined(); expect(stats).toHaveProperty('revenue'); expect(stats).toHaveProperty('sales'); expect(stats).toHaveProperty('views'); expect(stats).toHaveProperty('conversion'); }); }); describe('requestRefund', () => { it('should request refund successfully', async () => { const result = await commerceService.requestRefund( 'order-1', 'Defective product', ); expect(result).toBeDefined(); expect(result.success).toBe(true); }); }); });