/** * Component: Active Downloads Table Tests * Documentation: documentation/admin-dashboard.md */ // @vitest-environment jsdom import React from 'react'; import { render, screen } from '@testing-library/react'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { ActiveDownloadsTable } from '@/app/admin/components/ActiveDownloadsTable'; describe('ActiveDownloadsTable', () => { afterEach(() => { vi.useRealTimers(); }); it('renders an empty state when no downloads exist', () => { render(); expect(screen.getByText('No Active Downloads')).toBeInTheDocument(); }); it('renders download details with formatted values', () => { vi.useFakeTimers(); vi.setSystemTime(new Date('2024-01-01T00:00:00Z')); render( ); expect(screen.getByText('Active Book')).toBeInTheDocument(); expect(screen.getByText('Author One')).toBeInTheDocument(); expect(screen.getByText('42%')).toBeInTheDocument(); expect(screen.getByText('1 MB/s')).toBeInTheDocument(); expect(screen.getByText('1h 0m')).toBeInTheDocument(); expect(screen.getByText(/ago/)).toBeInTheDocument(); }); });