blade('Until the expiry.');
expect($html)
->toContain('toContain('wire:ignore.self')
->toContain(' open ')
->toContain('rounded-corner-lg bg-surface-container')
->toContain('data-collapse')
->toContain('[interpolate-size:allow-keywords]')
->toContain('How long do links last?')
->toContain('Until the expiry.')
->toContain('group-open/collapse:rotate-180');
});
it('has no Alpine on it without a binding', function () {
$html = (string) $this->blade('Body');
expect($html)
->toMatch('/not->toContain('x-data')
->not->toContain('x-modelable')
->not->toContain('x-on:toggle')
->and((string) $this->blade('Body'))
->toMatch('/blade('Body');
expect($html)
->toMatch('/x-data="{ collapseOpen:\s*true\s*}"/')
->toContain('x-modelable="collapseOpen"')
->toContain('x-model="advanced"')
->toContain('x-effect="$el.open = collapseOpen"')
->toContain('x-on:toggle="collapseOpen = $el.open"')
->toMatch('/\sopen\s/');
});
it('entangles its open state with a Livewire property and renders open as the property is', function (bool $fineTuning) {
Livewire::component('collapse-probe', new class extends Component
{
public bool $fineTuning = false;
public function render(): string
{
return 'Body
';
}
});
$html = Livewire::test('collapse-probe', ['fineTuning' => $fineTuning])->html();
expect($html)
->toContain(".entangle('fineTuning').live")
->not->toContain('x-modelable')
->not->toContain('wire:model');
preg_match('/]*>/', $html, $tag);
expect(preg_match('/\sopen\s/', $tag[0]) === 1)->toBe($fineTuning);
})->with(['open' => true, 'closed' => false]);