import { render } from '@testing-library/react' import { describe, expect, it } from 'vitest' import DocumentFileIcon from './document-file-icon' describe('DocumentFileIcon', () => { describe('Rendering', () => { it('should render without crashing', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should render FileTypeIcon component', () => { const { container } = render() // FileTypeIcon renders an svg or img element expect(container.querySelector('svg, img')).toBeInTheDocument() }) }) describe('Props', () => { it('should determine type from extension prop', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should determine type from name when extension not provided', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle uppercase extension', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle uppercase name extension', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should apply custom className', () => { const { container } = render() expect(container.querySelector('.custom-icon')).toBeInTheDocument() }) it('should pass size prop to FileTypeIcon', () => { // Testing different size values const { container: smContainer } = render() const { container: lgContainer } = render() expect(smContainer.firstChild).toBeInTheDocument() expect(lgContainer.firstChild).toBeInTheDocument() }) }) describe('File Type Mapping', () => { const testCases = [ { extension: 'pdf', description: 'PDF files' }, { extension: 'json', description: 'JSON files' }, { extension: 'html', description: 'HTML files' }, { extension: 'txt', description: 'TXT files' }, { extension: 'markdown', description: 'Markdown files' }, { extension: 'md', description: 'MD files' }, { extension: 'xlsx', description: 'XLSX files' }, { extension: 'xls', description: 'XLS files' }, { extension: 'csv', description: 'CSV files' }, { extension: 'doc', description: 'DOC files' }, { extension: 'docx', description: 'DOCX files' }, ] testCases.forEach(({ extension, description }) => { it(`should handle ${description}`, () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) }) }) describe('Edge Cases', () => { it('should handle unknown extension with default document type', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle empty extension string', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle name without extension', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle name with multiple dots', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should prioritize extension over name', () => { // If both are provided, extension should take precedence const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should handle undefined extension and name', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) it('should apply default size of md', () => { const { container } = render() expect(container.firstChild).toBeInTheDocument() }) }) })