import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { StatBand } from './StatBand';
import React from 'react';
describe('StatBand', () => {
it('renders each stat value and label', () => {
render(
);
expect(screen.getByText('$5.5T')).toBeInTheDocument();
expect(screen.getByText('Market opportunity')).toBeInTheDocument();
expect(screen.getByText('3x')).toBeInTheDocument();
expect(screen.getByText('Faster time to value')).toBeInTheDocument();
});
it('defaults columns to the number of stats, capped at 4', () => {
const { container, rerender } = render(
);
expect(container.firstChild).toHaveClass('md:grid-cols-2');
rerender(
);
expect(container.firstChild).toHaveClass('md:grid-cols-4');
});
it('honors an explicit columns prop over the default', () => {
const { container } = render(
);
expect(container.firstChild).toHaveClass('md:grid-cols-3');
});
it('applies the color token to each stat value', () => {
render(
);
expect(screen.getByText('99%')).toHaveClass('text-success');
expect(screen.getByText('9M+')).toHaveClass('text-primary');
});
it('adds a left border to stats that are not first in their row', () => {
render(
);
const firstStatValue = screen.getByText('1');
const secondStatValue = screen.getByText('2');
expect(firstStatValue.parentElement).not.toHaveClass('md:border-l');
expect(secondStatValue.parentElement).toHaveClass('md:border-l');
});
});