60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
/**
|
|
* Tests for FeatureGridBlock component
|
|
*/
|
|
import { render, screen } from '@testing-library/react';
|
|
import { FeatureGridBlock } from '../FeatureGridBlock';
|
|
|
|
describe('FeatureGridBlock', () => {
|
|
const mockFeatures = [
|
|
{ title: 'Feature 1', description: 'Description 1' },
|
|
{ title: 'Feature 2', description: 'Description 2' },
|
|
{ title: 'Feature 3' },
|
|
];
|
|
|
|
it('renders heading when provided', () => {
|
|
render(<FeatureGridBlock heading="Features" features={mockFeatures} />);
|
|
expect(screen.getByText('Features')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders all features', () => {
|
|
render(<FeatureGridBlock features={mockFeatures} />);
|
|
expect(screen.getByText('Feature 1')).toBeInTheDocument();
|
|
expect(screen.getByText('Feature 2')).toBeInTheDocument();
|
|
expect(screen.getByText('Feature 3')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders feature descriptions when provided', () => {
|
|
render(<FeatureGridBlock features={mockFeatures} />);
|
|
expect(screen.getByText('Description 1')).toBeInTheDocument();
|
|
expect(screen.getByText('Description 2')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders feature icons when provided', () => {
|
|
const featuresWithIcons = [
|
|
{ title: 'Feature 1', icon: '🚀' },
|
|
{ title: 'Feature 2', icon: '⭐' },
|
|
];
|
|
render(<FeatureGridBlock features={featuresWithIcons} />);
|
|
expect(screen.getByText('🚀')).toBeInTheDocument();
|
|
expect(screen.getByText('⭐')).toBeInTheDocument();
|
|
});
|
|
|
|
it('uses default columns value of 3', () => {
|
|
const { container } = render(<FeatureGridBlock features={mockFeatures} />);
|
|
const grid = container.querySelector('.shared-grid--3');
|
|
expect(grid).toBeInTheDocument();
|
|
});
|
|
|
|
it('applies correct columns class', () => {
|
|
const { container } = render(<FeatureGridBlock features={mockFeatures} columns={2} />);
|
|
const grid = container.querySelector('.shared-grid--2');
|
|
expect(grid).toBeInTheDocument();
|
|
});
|
|
|
|
it('handles empty features array', () => {
|
|
render(<FeatureGridBlock features={[]} />);
|
|
expect(screen.queryByRole('article')).not.toBeInTheDocument();
|
|
});
|
|
});
|
|
|