blade('| a |
'))
->toContain('
')
->and((string) $this->blade(''))->toContain('data-size="xs"')
->and((string) $this->blade(''))->toContain('data-size="sm"');
});
it('sorts by its column, ascending first and then flipping', function () {
expect((string) $this->blade('Size'))
->not->toContain('aria-sort')
->toContain('wire:click="$set(\'sortBy\', {"column":"size","direction":"asc"})"')
->and((string) $this->blade('Size'))
->toContain('aria-sort="ascending"')
->toContain('class="text-end"')
->toContain('$set(\'order\', {"column":"size","direction":"desc"})')
->and((string) $this->blade('Size'))
->toContain('aria-sort="descending"')
->toContain('"direction":"asc"');
});
it('gives the sort button and every page control a 48px target', function () {
$pages = new LengthAwarePaginator(range(1, 10), 95, 10, 3, ['path' => '/shares']);
expect((string) $this->blade('Size'))
->toContain('touch-target')
->and((string) $pages->links())
->toContain('state-layer focus-ring touch-target');
});
it('draws Laravel\'s paginators in M3', function () {
$pages = new LengthAwarePaginator(range(1, 10), 95, 10, 3, ['path' => '/shares']);
expect((string) $pages->links())
->toContain('data-pagination')
->toContain('Page 3 of 10')
->toContain('21–30 of 95')
->toContain('3')
->toContain('href="/shares?page=2" rel="prev"')
->toContain('aria-label="Go to page 4"')
->not->toContain('text-gray');
expect((string) (new Paginator(range(1, 11), 10, 2, ['path' => '/shares']))->links())
->toContain('data-pagination')
->toContain('href="/shares?page=1"')
->toContain('href="/shares?page=3"')
->toContain('Previous');
});
it('draws Livewire\'s paginators in M3, wired to its page actions', function () {
Livewire::component('paging-probe', new class extends Component
{
use WithPagination;
public function render(): string
{
return <<<'BLADE'
{{ (new \Illuminate\Pagination\LengthAwarePaginator(range(1, 10), 95, 10, $this->getPage(), ['path' => '/'])) ->links() }}
BLADE;
}
});
expect(Livewire::test('paging-probe')->html())
->toContain('data-pagination')
->toContain('wire:click="gotoPage(2, \'page\')"')
->toContain('wire:click="nextPage(\'page\')"')
->not->toContain('text-gray');
});