Skip to content

Commit c612abd

Browse files
committed
Add test for search panes options response.
1 parent c69a136 commit c612abd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/Integration/QueryDataTableTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Yajra\DataTables\Facades\DataTables as DatatablesFacade;
1111
use Yajra\DataTables\QueryDataTable;
1212
use Yajra\DataTables\Tests\TestCase;
13+
use Yajra\DataTables\Tests\Models\User;
1314

1415
class QueryDataTableTest extends TestCase
1516
{
@@ -229,6 +230,27 @@ public function it_allows_search_on_added_column_with_custom_filter_handler()
229230
$this->assertStringContainsString('"1" = ?', $queries[1]['query']);
230231
}
231232

233+
/** @test */
234+
public function it_returns_search_panes_options()
235+
{
236+
$crawler = $this->call('GET', '/query/search-panes');
237+
238+
$crawler->assertJson([
239+
'draw' => 0,
240+
'recordsTotal' => 20,
241+
'recordsFiltered' => 20,
242+
'searchPanes' => [
243+
'options' => [
244+
'name' => []
245+
],
246+
]
247+
]);
248+
249+
$options = $crawler->json()['searchPanes']['options'];
250+
251+
$this->assertEquals(count($options['name']), 20);
252+
}
253+
232254
/** @test */
233255
public function it_allows_column_search_added_column_with_custom_filter_handler()
234256
{
@@ -328,5 +350,13 @@ protected function setUp(): void
328350
->rawColumns(['name', 'email'])
329351
->toJson();
330352
});
353+
354+
$route->get('/query/search-panes', function (DataTables $dataTable) {
355+
$options = User::select('id as value', 'name as label')->get();
356+
357+
return $dataTable->query(DB::table('users'))
358+
->searchPanes('name', $options)
359+
->toJson();
360+
});
331361
}
332362
}

0 commit comments

Comments
 (0)