Skip to content

Commit bb000c6

Browse files
committed
Apply Separate Tests
1 parent 2642368 commit bb000c6

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/Unit/Traits/Helpers/ColumnSelectHelpersTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,63 @@ public function configure(): void
143143
Event::assertDispatched(ColumnsSelected::class);
144144

145145
}
146+
147+
public function test_event_does_fire_for_columnselect(): void
148+
{
149+
Event::fake();
150+
151+
$testTable = new class extends PetsTable
152+
{
153+
public function configure(): void
154+
{
155+
parent::configure();
156+
$this->enableColumnSelectEvent();
157+
}
158+
};
159+
$testTable->configure();
160+
$testTable->boot();
161+
$testTable->bootedComponentUtilities();
162+
$testTable->bootedWithData();
163+
$testTable->bootedWithColumns();
164+
$testTable->bootedWithColumnSelect();
165+
$testTable->bootedWithSecondaryHeader();
166+
$testTable->booted();
167+
168+
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
169+
170+
$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'];
171+
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
172+
$testTable->updatedSelectedColumns();
173+
Event::assertDispatched(ColumnsSelected::class);
174+
175+
}
176+
177+
public function test_event_does_not_fire_for_columnselect(): void
178+
{
179+
Event::fake();
180+
181+
$testTable = new class extends PetsTable
182+
{
183+
public function configure(): void
184+
{
185+
parent::configure();
186+
$this->disableColumnSelectEvent();
187+
}
188+
};
189+
$testTable->configure();
190+
$testTable->boot();
191+
$testTable->bootedComponentUtilities();
192+
$testTable->bootedWithData();
193+
$testTable->bootedWithColumns();
194+
$testTable->bootedWithColumnSelect();
195+
$testTable->bootedWithSecondaryHeader();
196+
$testTable->booted();
197+
198+
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'link', 'rowimg'], $testTable->selectedColumns);
199+
$testTable->selectedColumns = ['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'];
200+
$this->assertSame(['id', 'sort', 'name', 'age', 'breed', 'other', 'rowimg'], $testTable->selectedColumns);
201+
$testTable->updatedSelectedColumns();
202+
Event::assertNotDispatched(ColumnsSelected::class);
203+
}
204+
146205
}

0 commit comments

Comments
 (0)