import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { ServiceCardGrid } from './ServiceCardGrid';
import React from 'react';
describe('ServiceCardGrid', () => {
it('renders each item title and description in the default card variant', () => {
render(
);
expect(screen.getByText('AI Strategy')).toBeInTheDocument();
expect(screen.getByText('Define a roadmap for responsible adoption.')).toBeInTheDocument();
expect(screen.getByText('Implementation')).toBeInTheDocument();
});
it('renders the category label and checklist items with check icons', () => {
const { container } = render(
);
expect(screen.getByText('Compliance')).toBeInTheDocument();
expect(screen.getByText('SOC 2 mapping')).toBeInTheDocument();
expect(screen.getByText('Model risk register')).toBeInTheDocument();
expect(container.querySelectorAll('svg').length).toBeGreaterThan(0);
});
it('renders a bullet list when bullets are provided instead of a checklist', () => {
render(
);
expect(screen.getAllByRole('listitem')).toHaveLength(2);
expect(screen.getByText('BigQuery-native')).toBeInTheDocument();
});
it('renders a CTA as a link when href is provided', () => {
render(
);
expect(screen.getByRole('link', { name: 'Learn more' })).toHaveAttribute(
'href',
'/managed-services'
);
});
it('ignores checklist, bullets, and CTA chrome in the plain variant', () => {
render(
);
expect(screen.getByText('Advisory')).toBeInTheDocument();
expect(screen.queryByText('Should not render')).not.toBeInTheDocument();
expect(screen.queryByText('Should not render either')).not.toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'Should not render' })).not.toBeInTheDocument();
});
it('applies the correct desktop column class based on the columns prop', () => {
const { container, rerender } = render(
);
expect(container.firstChild).toHaveClass('md:grid-cols-2');
rerender();
expect(container.firstChild).toHaveClass('md:grid-cols-4');
rerender();
expect(container.firstChild).toHaveClass('md:grid-cols-3');
});
});