Fixed event dispatching. Added tests.
This commit is contained in:
@@ -26,7 +26,7 @@ class LivewirePieChart extends Component
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit($onSliceClickEventName, $slice);
|
||||
$this->dispatch($onSliceClickEventName, $slice);
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user