|
2 | 2 |
|
3 | 3 | namespace Yajra\DataTables\Html\Tests; |
4 | 4 |
|
| 5 | +use Illuminate\Support\HtmlString; |
5 | 6 | use Yajra\DataTables\Html\Builder; |
6 | 7 | use Yajra\DataTables\Html\Column; |
7 | 8 | use Yajra\DataTables\Html\ColumnDefinition; |
@@ -209,4 +210,26 @@ public function it_has_column_defs() |
209 | 210 | $this->assertEquals([['targets' => 1]], $builder->getAttribute('columnDefs')); |
210 | 211 | $this->assertCount(1, $builder->getAttribute('columnDefs')); |
211 | 212 | } |
| 213 | + |
| 214 | + /** @test */ |
| 215 | + public function it_has_table_options() |
| 216 | + { |
| 217 | + $builder = $this->getHtmlBuilder(); |
| 218 | + $builder->setTableId('my-table'); |
| 219 | + |
| 220 | + $this->assertEquals('my-table', $builder->getTableId()); |
| 221 | + $this->assertEquals(['id' => 'my-table', 'class' => 'table'], $builder->getTableAttributes()); |
| 222 | + |
| 223 | + $builder->setTableAttribute('class', 'dTable'); |
| 224 | + $this->assertEquals(['id' => 'my-table', 'class' => 'dTable'], $builder->getTableAttributes()); |
| 225 | + |
| 226 | + $builder->addTableClass('table'); |
| 227 | + $this->assertEquals(['id' => 'my-table', 'class' => 'dTable table'], $builder->getTableAttributes()); |
| 228 | + |
| 229 | + $builder->removeTableClass('dTable'); |
| 230 | + $this->assertEquals(['id' => 'my-table', 'class' => 'table'], $builder->getTableAttributes()); |
| 231 | + |
| 232 | + $this->assertInstanceOf(HtmlString::class, $builder->table()); |
| 233 | + $this->assertEquals('<table class="table" id="my-table"><thead><tr></tr></thead></table>', $builder->table()->toHtml()); |
| 234 | + } |
212 | 235 | } |
0 commit comments