Skip to content

Commit

Permalink
adds tests for bulkActions() function
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-ivona committed Sep 24, 2021
1 parent b7889bc commit 0064bd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/DataTableComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,11 @@ public function search_filter_alt_query_relation()
$this->tableAltQuery->filters['search'] = 'Cat';
$this->assertEquals(2, $this->tableAltQuery->rows->total());
}

/** @test */
public function bulk_actions_defined_with_function()
{
$this->table->selected[] = 1;
$this->assertEquals(1, $this->table->count());
}
}
10 changes: 10 additions & 0 deletions tests/Http/Livewire/PetsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

class PetsTable extends DataTableComponent
{
public function bulkActions(): array
{
return [ 'count' => 'Count selected'];
}

/**
* @return Builder
*/
Expand Down Expand Up @@ -36,4 +41,9 @@ public function columns(): array
->searchable(),
];
}

public function count(): int
{
return $this->selectedRowsQuery()->count();
}
}

0 comments on commit 0064bd8

Please sign in to comment.