82 lines
2.3 KiB
TypeScript
82 lines
2.3 KiB
TypeScript
/**
|
|
* AdminDashboardLayout Component Tests
|
|
*
|
|
* Tests for the AdminDashboardLayout component that provides a consistent
|
|
* container layout for admin pages.
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { AdminDashboardLayout } from './AdminDashboardLayout';
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('AdminDashboardLayout', () => {
|
|
it('should render children content', () => {
|
|
render(
|
|
<AdminDashboardLayout>
|
|
<div data-testid="content">Dashboard Content</div>
|
|
</AdminDashboardLayout>
|
|
);
|
|
|
|
expect(screen.getByTestId('content')).toBeTruthy();
|
|
expect(screen.getByText('Dashboard Content')).toBeTruthy();
|
|
});
|
|
|
|
it('should render multiple children', () => {
|
|
render(
|
|
<AdminDashboardLayout>
|
|
<div>Section 1</div>
|
|
<div>Section 2</div>
|
|
<div>Section 3</div>
|
|
</AdminDashboardLayout>
|
|
);
|
|
|
|
expect(screen.getByText('Section 1')).toBeTruthy();
|
|
expect(screen.getByText('Section 2')).toBeTruthy();
|
|
expect(screen.getByText('Section 3')).toBeTruthy();
|
|
});
|
|
|
|
it('should render with complex nested components', () => {
|
|
const ComplexComponent = () => (
|
|
<div>
|
|
<h2>Complex Section</h2>
|
|
<p>With multiple elements</p>
|
|
<button>Action</button>
|
|
</div>
|
|
);
|
|
|
|
render(
|
|
<AdminDashboardLayout>
|
|
<ComplexComponent />
|
|
</AdminDashboardLayout>
|
|
);
|
|
|
|
expect(screen.getByText('Complex Section')).toBeTruthy();
|
|
expect(screen.getByText('With multiple elements')).toBeTruthy();
|
|
expect(screen.getByText('Action')).toBeTruthy();
|
|
});
|
|
|
|
it('should render empty layout gracefully', () => {
|
|
render(<AdminDashboardLayout />);
|
|
|
|
// Should render without errors even with no children
|
|
expect(document.body).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render with mixed content types', () => {
|
|
render(
|
|
<AdminDashboardLayout>
|
|
<div>Text content</div>
|
|
<span>Span content</span>
|
|
<button>Button</button>
|
|
<input type="text" placeholder="Input" />
|
|
</AdminDashboardLayout>
|
|
);
|
|
|
|
expect(screen.getByText('Text content')).toBeInTheDocument();
|
|
expect(screen.getByText('Span content')).toBeInTheDocument();
|
|
expect(screen.getByText('Button')).toBeInTheDocument();
|
|
expect(screen.getByPlaceholderText('Input')).toBeInTheDocument();
|
|
});
|
|
});
|