'Hero Title']) ); $result = $renderer->render($block); expect($result)->toHaveKeys(['component', 'data']); expect($result['component'])->toBe('cms/hero'); expect($result['data']['title'])->toBe('Hero Title'); }); it('renders hero block with all fields', function () { $renderer = new HeroBlockRenderer(); $block = ContentBlock::create( type: BlockType::hero(), blockId: BlockId::fromString('hero-1'), data: BlockData::fromArray([ 'title' => 'Hero Title', 'subtitle' => 'Hero Subtitle', 'backgroundImage' => 'img-123', 'ctaText' => 'Click Me', 'ctaLink' => '/signup', ]), settings: BlockSettings::fromArray([ 'fullWidth' => true, 'padding' => 'large', ]) ); $result = $renderer->render($block); expect($result['data']['title'])->toBe('Hero Title'); expect($result['data']['subtitle'])->toBe('Hero Subtitle'); expect($result['data']['backgroundImage'])->toBe('img-123'); expect($result['data']['ctaText'])->toBe('Click Me'); expect($result['data']['ctaLink'])->toBe('/signup'); expect($result['data']['fullWidth'])->toBeTrue(); expect($result['data']['padding'])->toBe('large'); }); it('handles snake_case field names', function () { $renderer = new HeroBlockRenderer(); $block = ContentBlock::create( type: BlockType::hero(), blockId: BlockId::fromString('hero-1'), data: BlockData::fromArray([ 'title' => 'Hero Title', 'background_image' => 'img-123', 'cta_text' => 'Click Me', 'cta_link' => '/signup', ]), settings: BlockSettings::fromArray(['full_width' => true]) ); $result = $renderer->render($block); expect($result['data']['backgroundImage'])->toBe('img-123'); expect($result['data']['ctaText'])->toBe('Click Me'); expect($result['data']['ctaLink'])->toBe('/signup'); expect($result['data']['fullWidth'])->toBeTrue(); }); it('provides default values for missing fields', function () { $renderer = new HeroBlockRenderer(); $block = ContentBlock::create( type: BlockType::hero(), blockId: BlockId::fromString('hero-1'), data: BlockData::fromArray(['title' => 'Hero Title']) ); $result = $renderer->render($block); expect($result['data']['title'])->toBe('Hero Title'); expect($result['data']['subtitle'])->toBeNull(); expect($result['data']['fullWidth'])->toBeFalse(); expect($result['data']['padding'])->toBe('medium'); }); it('supports hero block type', function () { $renderer = new HeroBlockRenderer(); expect($renderer->supports('hero'))->toBeTrue(); expect($renderer->supports('text'))->toBeFalse(); expect($renderer->supports('image'))->toBeFalse(); }); });