Skip to content

Commit 0064bd8

Browse files
committed
adds tests for bulkActions() function
1 parent b7889bc commit 0064bd8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/DataTableComponentTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,11 @@ public function search_filter_alt_query_relation()
114114
$this->tableAltQuery->filters['search'] = 'Cat';
115115
$this->assertEquals(2, $this->tableAltQuery->rows->total());
116116
}
117+
118+
/** @test */
119+
public function bulk_actions_defined_with_function()
120+
{
121+
$this->table->selected[] = 1;
122+
$this->assertEquals(1, $this->table->count());
123+
}
117124
}

tests/Http/Livewire/PetsTable.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
class PetsTable extends DataTableComponent
1111
{
12+
public function bulkActions(): array
13+
{
14+
return [ 'count' => 'Count selected'];
15+
}
16+
1217
/**
1318
* @return Builder
1419
*/
@@ -36,4 +41,9 @@ public function columns(): array
3641
->searchable(),
3742
];
3843
}
44+
45+
public function count(): int
46+
{
47+
return $this->selectedRowsQuery()->count();
48+
}
3949
}

0 commit comments

Comments
 (0)