Skip to content

Commit

Permalink
Fixed error dispatching
Browse files Browse the repository at this point in the history
  • Loading branch information
asantibanez committed Jul 25, 2023
1 parent 5034771 commit 55d76bc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Charts/LivewireColumnChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function onColumnClick($column)
return;
}

$this->emit($onColumnClickEventName, $column);
$this->dispatch($onColumnClickEventName, $column);
}

public function render()
Expand Down
19 changes: 19 additions & 0 deletions tests/LivewireColumnChartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit 55d76bc

Please sign in to comment.