Fixed event dispatching. Added tests.

This commit is contained in:
asantibanez
2023-07-25 16:19:04 -05:00
parent aa822000af
commit 2d9bcfe480
2 changed files with 20 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ class LivewirePieChart extends Component
return;
}
$this->emit($onSliceClickEventName, $slice);
$this->dispatch($onSliceClickEventName, $slice);
}
public function render()

View File

@@ -22,4 +22,23 @@ class LivewirePieChartTest extends TestCase
//Assert
$this->assertNotNull($component);
}
/** @test */
public function should_emit_event_if_present()
{
//Arrange
$component = $this->buildComponent();
$pieChartModel = $component->pieChartModel;
data_set($pieChartModel, 'onSliceClickEventName', 'custom-event');
$component->set('pieChartModel', $pieChartModel);
//Act
$component->runAction('onSliceClick', []);
//Assert
$component->assertDispatched('custom-event');
}
}