/**
* EchoDashLogo Component Tests
*
* Unit tests for the EchoDashLogo component including props handling
* and accessibility features.
*/
import React from 'react';
import { render } from '@testing-library/react';
import { EchoDashLogo } from './EchoDashLogo';
describe('EchoDashLogo Component', () => {
describe('Default Rendering', () => {
it('renders with default props', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toBeInTheDocument();
expect(logo).toHaveAttribute('width', '189');
expect(logo).toHaveAttribute('height', '36');
expect(logo).toHaveAttribute('aria-label', 'EchoDash');
});
it('renders with default empty className', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('class', '');
});
});
describe('Props Handling', () => {
it('renders with custom width and height as numbers', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('width', '200');
expect(logo).toHaveAttribute('height', '40');
});
it('renders with custom width and height as strings', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('width', '100%');
expect(logo).toHaveAttribute('height', 'auto');
});
it('renders with custom className', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveClass('custom-logo-class');
});
it('handles undefined className gracefully', () => {
// Test the default parameter fallback (line 10)
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('class', '');
});
it('combines all props correctly', () => {
render(
);
const logo = document.querySelector('svg');
expect(logo).toHaveClass('logo-container');
expect(logo).toHaveAttribute('width', '250');
expect(logo).toHaveAttribute('height', '50');
});
});
describe('SVG Structure and Accessibility', () => {
it('has correct viewBox and namespace', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('viewBox', '0 0 189 36');
expect(logo).toHaveAttribute('xmlns', 'http://www.w3.org/2000/svg');
expect(logo).toHaveAttribute('fill', 'none');
});
it('has proper accessibility attributes', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('aria-label', 'EchoDash');
});
it('contains expected number of path elements', () => {
render();
const paths = document.querySelectorAll('path');
expect(paths).toHaveLength(9); // Based on the actual SVG structure
});
it('has correct fill color for all paths', () => {
render();
const paths = document.querySelectorAll('path');
paths.forEach(path => {
expect(path).toHaveAttribute('fill', '#202E41');
});
});
});
describe('Edge Cases', () => {
it('handles zero width and height', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('width', '0');
expect(logo).toHaveAttribute('height', '0');
});
it('handles negative width and height', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('width', '-100');
expect(logo).toHaveAttribute('height', '-50');
});
it('handles empty string className', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveAttribute('class', '');
});
it('handles multiple CSS classes', () => {
render();
const logo = document.querySelector('svg');
expect(logo).toHaveClass('class1', 'class2', 'class3');
});
});
});