import React from 'react';
import { describe, it, expect } from 'vitest';
import { render } from '@testing-library/react';
import { PixelSection } from '../../layout';
describe('PixelSection (upgrade)', () => {
it('renders without a title (title is optional)', () => {
const { container, queryByRole } = render(
body
,
);
expect(queryByRole('heading', { level: 3 })).toBeNull();
expect(container.querySelector('section')).not.toBeNull();
expect(container.textContent).toContain('body');
});
it('renders heading when title is provided', () => {
const { getByRole } = render(
body
,
);
const h = getByRole('heading', { level: 3 });
expect(h.textContent?.toLowerCase()).toContain('hello');
});
it('wraps content in PixelCenter container by default (max-w-[1600px])', () => {
const { container } = render(
body
,
);
// PixelCenter applies max-w-[1600px] by default ('5xl')
expect(container.innerHTML).toContain('max-w-[1600px]');
});
it('container={false} disables the centered wrapper and applies horizontalGutter on section', () => {
const { container } = render(
body
,
);
const section = container.querySelector('section')!;
expect(section.className).toContain('px-4');
expect(section.className).toContain('sm:px-6');
// no inner PixelCenter wrapper width applied
expect(container.innerHTML).not.toContain('max-w-[1600px]');
});
it('verticalPadding="xl" applies py-20 sm:py-28 lg:py-32 by default', () => {
const { container } = render(
body
,
);
const section = container.querySelector('section')!;
expect(section.className).toContain('py-20');
expect(section.className).toContain('sm:py-28');
expect(section.className).toContain('lg:py-32');
});
it('verticalPadding="none" applies py-0', () => {
const { container } = render(
body
,
);
const section = container.querySelector('section')!;
expect(section.className).toContain('py-0');
});
it('container="prose" forwards to PixelCenter (max-w-prose)', () => {
const { container } = render(
body
,
);
expect(container.innerHTML).toContain('max-w-prose');
});
});