import type { EvaluatedBlock } from '@ministryofjustice/hmpps-forge/core/components' import { GovUKButtonGroup } from './govukButtonGroup' const render = (props: Record) => GovUKButtonGroup.render(props as EvaluatedBlock) const renderedButton = (html: string) => ({ block: { variant: 'govukButton' }, html }) describe('GovUKButtonGroup', () => { describe('block building', () => { it('should stamp the govukButtonGroup variant when called as a builder', () => { // Arrange & Act const built = GovUKButtonGroup({ buttons: [] }) // Assert expect(built.variant).toBe('govukButtonGroup') }) }) describe('rendering', () => { it('should wrap rendered child buttons in the button group div', () => { // Arrange const buttons = [ renderedButton(''), renderedButton('Cancel'), ] // Act const output = render({ buttons }) // Assert expect(output).toBe( '
' + '' + 'Cancel' + '
', ) }) it('should embed child HTML verbatim without escaping', () => { // Arrange const buttons = [renderedButton('')] // Act const output = render({ buttons }) // Assert expect(output).toBe('
') }) it('should render an empty group when there are no buttons', () => { // Arrange & Act const output = render({ buttons: [] }) // Assert expect(output).toBe('
') }) it('should append additional classes and attributes', () => { // Arrange & Act const output = render({ buttons: [], classes: 'app-actions', attributes: { 'data-qa': 'actions' } }) // Assert expect(output).toBe('
') }) }) })