blade('')) ->toContain('role="group"') ->toContain('aria-label="Views"') ->toContain('data-button-group="standard"') ->toContain('data-size="md"') ->toContain('gap-2') ->and((string) $this->blade('')) ->toContain('gap-3'); }); it('connects buttons 2px apart', function () { expect((string) $this->blade('')) ->toContain('data-button-group="connected"') ->toContain('gap-0.5'); }); it('squares a group', function () { // M3 lists "Default shape | Round, square" as a button-group configuration; the shape covers // every button in the group, so it need not be written on each one. expect((string) $this->blade('')) ->toContain('data-shape="square"') ->and((string) $this->blade('')) ->toContain('data-button-group="connected"') ->toContain('data-shape="square"') ->and((string) $this->blade('')) ->toContain('data-shape="round"'); }); it('takes over aria-pressed for a group that carries a selection', function () { $html = (string) $this->blade(''); expect($html) ->toContain('data-selection="single"') ->toContain('data-selection-required') ->toContain('multiple: false') ->toContain('required: true') ->toContain('value: null') ->toContain('x-on:click="press($event)"') // No model: the group takes the state from the buttons' own aria-pressed and goes on. ->toContain('x-modelable="value"') ->and((string) $this->blade('')) ->toContain('multiple: true') ->toContain('required: false') ->toContain('value: []') ->and((string) $this->blade('')) ->not->toContain('data-selection') ->not->toContain('press($event)'); }); it('entangles a selection group with the property it binds, and keeps wire:model off the div', function () { $component = new class extends Component { public string $view = 'week'; public function render(): string { return <<<'BLADE'
BLADE; } }; $html = Livewire::test($component)->assertSet('view', 'week')->html(); expect($html) ->toContain('data-selection="single"') ->toMatch('/value: window\.Livewire\.find\(/') ->and(substr_count($html, 'wire:model.live="view"'))->toBe(0); }); it('never wraps a group onto a second line', function () { expect((string) $this->blade('')) ->not->toContain('flex-wrap'); }); it('marks icon buttons, which keep their width when a group is pressed', function () { expect((string) $this->blade(''))->toContain('data-md-icon-button') ->and((string) $this->blade(''))->not->toContain('data-md-icon-button'); });