diff --git a/src/Charts/LivewireColumnChart.php b/src/Charts/LivewireColumnChart.php index 753d6cb..912cb0d 100644 --- a/src/Charts/LivewireColumnChart.php +++ b/src/Charts/LivewireColumnChart.php @@ -26,7 +26,7 @@ public function onColumnClick($column) return; } - $this->emit($onColumnClickEventName, $column); + $this->dispatch($onColumnClickEventName, $column); } public function render() diff --git a/tests/LivewireColumnChartTest.php b/tests/LivewireColumnChartTest.php index 6b78643..949929d 100755 --- a/tests/LivewireColumnChartTest.php +++ b/tests/LivewireColumnChartTest.php @@ -22,4 +22,23 @@ public function can_build_component() //Assert $this->assertNotNull($component); } + + /** @test */ + public function should_emit_event_if_present() + { + //Arrange + $component = $this->buildComponent(); + + $columnChartModel = $component->columnChartModel; + + data_set($columnChartModel, 'onColumnClickEventName', 'custom-event'); + + $component->set('columnChartModel', $columnChartModel); + + //Act + $component->runAction('onColumnClick', []); + + //Assert + $component->assertDispatched('custom-event'); + } }