/** * AdminToolbar Component Tests * * Tests for the AdminToolbar component that provides a semantic toolbar * for admin pages with filters, search, and secondary actions. */ import React from 'react'; import { render, screen } from '@testing-library/react'; import { AdminToolbar } from './AdminToolbar'; import { describe, it, expect, vi } from 'vitest'; // Mock the ControlBar component vi.mock('@/ui/ControlBar', () => ({ ControlBar: ({ leftContent, children }: any) => (
{leftContent &&
{leftContent}
}
{children}
), })); describe('AdminToolbar', () => { it('should render with children only', () => { render( ); expect(screen.getByText('Filter')).toBeTruthy(); }); it('should render with leftContent and children', () => { render( Left Content} > ); expect(screen.getByText('Left Content')).toBeTruthy(); expect(screen.getByText('Filter')).toBeTruthy(); }); it('should render with multiple children', () => { render( Filters} > ); expect(screen.getByText('Filters')).toBeTruthy(); expect(screen.getByText('Filter 1')).toBeTruthy(); expect(screen.getByText('Filter 2')).toBeTruthy(); expect(screen.getByText('Filter 3')).toBeTruthy(); }); it('should render with complex leftContent', () => { const ComplexLeftContent = () => (
Complex
); render( } > ); expect(screen.getByText('Complex')).toBeTruthy(); expect(screen.getByText('Action')).toBeTruthy(); expect(screen.getByText('Filter')).toBeTruthy(); }); it('should render with complex children', () => { const ComplexChild = () => (
Complex
); render( Filters} > ); expect(screen.getByText('Filters')).toBeTruthy(); expect(screen.getByText('Complex')).toBeTruthy(); expect(screen.getByText('Action')).toBeTruthy(); }); it('should render with mixed content types', () => { render( Filters} > ); expect(screen.getByText('Filters')).toBeTruthy(); expect(screen.getByText('Button')).toBeTruthy(); expect(screen.getByPlaceholderText('Search')).toBeTruthy(); }); it('should render without leftContent', () => { render( ); expect(screen.getByText('Filter')).toBeTruthy(); }); it('should render with empty children', () => { render( Filters} > {null} ); expect(screen.getByText('Filters')).toBeTruthy(); }); });