Skip to content

Commit 81fd7e1

Browse files
committed
added test for allowed selects
1 parent 7252dbd commit 81fd7e1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/DatatableTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@
605605

606606
});
607607

608-
it('can get correct data with providing filter fn:`between` and datatype:`date`', function () {
608+
it('can get correct data with providing filter fn:`between` and datatype:`date` with selecting only specific columns', function () {
609609

610610
$expectedUsers = User::factory()
611611
->count(5)
@@ -635,14 +635,16 @@
635635
];
636636

637637
$allowedFilters = array('created_at');
638+
$allowedSelects = array('username', 'email', 'age');
638639

639640
$data = (new Datatable())->run(
640641
$query,
641642
$requestParameters,
642-
$allowedFilters
643+
$allowedFilters,
644+
allowedSelects: $allowedSelects
643645
);
644646

645-
$expected = $expectedUsers->toArray();
647+
$expected = $expectedUsers->map->only($allowedSelects)->toArray();
646648

647649
expect($data['data'])
648650
->toEqual($expected);
@@ -959,3 +961,4 @@
959961
//sorting
960962
// filter with rel
961963
// include relations test :)
964+
// allowed select test

0 commit comments

Comments
 (0)