ldc-boutique-cnc-sable/tests/Feature/Bo/Modules/ChangeOrderBladeTest.php

93 lines
2.9 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
use App\Models\Tag;
use Illuminate\Pagination\LengthAwarePaginator;
describe('change-order blade component', function (): void {
it('shows down arrow on the last item of page 1 when there are multiple pages', function (): void {
// GIVEN
$tag = new Tag();
$tag->id = 1;
$tag->order = 15;
$paginator = new LengthAwarePaginator([$tag], 30, 15, 1);
// WHEN
$html = view('bo.modules.change-order', [
'route' => 'bo.tags.change-order',
'model' => $tag,
'first' => false,
'last' => true,
'isFirstPage' => $paginator->onFirstPage(),
'isLastPage' => ! $paginator->hasMorePages(),
])->render();
// THEN
expect($html)->toContain('name="down_arrow"');
});
it('shows up arrow on the first item of page 2 when there are multiple pages', function (): void {
// GIVEN
$tag = new Tag();
$tag->id = 2;
$tag->order = 16;
$paginator = new LengthAwarePaginator([$tag], 30, 15, 2);
// WHEN
$html = view('bo.modules.change-order', [
'route' => 'bo.tags.change-order',
'model' => $tag,
'first' => true,
'last' => false,
'isFirstPage' => $paginator->onFirstPage(),
'isLastPage' => ! $paginator->hasMorePages(),
])->render();
// THEN
expect($html)->toContain('name="down_up"');
});
it('hides up arrow on the first item of the first page', function (): void {
// GIVEN
$tag = new Tag();
$tag->id = 1;
$tag->order = 1;
$paginator = new LengthAwarePaginator([$tag], 30, 15, 1);
// WHEN
$html = view('bo.modules.change-order', [
'route' => 'bo.tags.change-order',
'model' => $tag,
'first' => true,
'last' => false,
'isFirstPage' => $paginator->onFirstPage(),
'isLastPage' => ! $paginator->hasMorePages(),
])->render();
// THEN
expect($html)->not->toContain('name="down_up"');
});
it('hides down arrow on the last item of the last page', function (): void {
// GIVEN
$tag = new Tag();
$tag->id = 2;
$tag->order = 30;
$paginator = new LengthAwarePaginator([$tag], 30, 15, 2);
// WHEN
$html = view('bo.modules.change-order', [
'route' => 'bo.tags.change-order',
'model' => $tag,
'first' => false,
'last' => true,
'isFirstPage' => $paginator->onFirstPage(),
'isLastPage' => ! $paginator->hasMorePages(),
])->render();
// THEN
expect($html)->not->toContain('name="down_arrow"');
});
});