Fixed event dispatching. Added tests.
This commit is contained in:
@@ -26,7 +26,7 @@ class LivewirePieChart extends Component
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->emit($onSliceClickEventName, $slice);
|
$this->dispatch($onSliceClickEventName, $slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
|||||||
@@ -22,4 +22,23 @@ class LivewirePieChartTest extends TestCase
|
|||||||
//Assert
|
//Assert
|
||||||
$this->assertNotNull($component);
|
$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