|
5 | 5 |
|
6 | 6 | use function PowerComponents\LivewirePowerGrid\Tests\Plugins\livewire;
|
7 | 7 |
|
| 8 | +use PowerComponents\LivewirePowerGrid\{Button,Column}; |
| 9 | + |
8 | 10 | it('properly export xls - all data', function () {
|
9 | 11 | livewire(ExportTable::class)
|
10 | 12 | ->call('exportToXLS', false)
|
|
85 | 87 | expect()->notToBeFileDownloaded($component);
|
86 | 88 | })->requiresOpenSpout();
|
87 | 89 |
|
| 90 | +$exportWithAction = new class () extends ExportTable { |
| 91 | + public function columns(): array |
| 92 | + { |
| 93 | + return [ |
| 94 | + Column::action('Foo') |
| 95 | + ->visibleInExport(true), |
| 96 | + ]; |
| 97 | + } |
| 98 | + |
| 99 | + public function actions($row): array |
| 100 | + { |
| 101 | + return [ |
| 102 | + Button::add('Foo'), |
| 103 | + ]; |
| 104 | + } |
| 105 | +}; |
| 106 | + |
| 107 | +it('properly export xls with action', function (string $component) { |
| 108 | + $downloadedFile = livewire($component) |
| 109 | + ->call('exportToXLS', false) |
| 110 | + ->assertFileDownloaded('export.xlsx'); |
| 111 | + |
| 112 | + $headings = ['Foo']; |
| 113 | + |
| 114 | + expect($downloadedFile)->toBeXLSDownload($headings, []); |
| 115 | +})->with('export_with_action')->requiresOpenSpout(); |
| 116 | + |
| 117 | +it('properly export csv with action', function (string $component) { |
| 118 | + $downloadedFile = livewire($component) |
| 119 | + ->call('exportToCsv', false) |
| 120 | + ->assertFileDownloaded('export.csv'); |
| 121 | + |
| 122 | + $headings = ['Foo']; |
| 123 | + |
| 124 | + expect($downloadedFile)->toBeCsvDownload($headings, []); |
| 125 | +})->with('export_with_action')->requiresOpenSpout(); |
| 126 | + |
| 127 | +dataset('export_with_action', [ |
| 128 | + 'data' => [$exportWithAction::class], |
| 129 | +]); |
| 130 | + |
88 | 131 | /*
|
89 | 132 | |--------------------------------------------------------------------------
|
90 | 133 | | Expectations for this test
|
|
0 commit comments