Fixed error dispatching

This commit is contained in:
asantibanez
2023-07-25 16:51:53 -05:00
parent 5034771e57
commit 55d76bcecd
2 changed files with 20 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ class LivewireColumnChart extends Component
return; return;
} }
$this->emit($onColumnClickEventName, $column); $this->dispatch($onColumnClickEventName, $column);
} }
public function render() public function render()

View File

@@ -22,4 +22,23 @@ class LivewireColumnChartTest extends TestCase
//Assert //Assert
$this->assertNotNull($component); $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');
}
} }