feat: extract fuel.recommendation Livewire component
This commit is contained in:
52
tests/Feature/Livewire/Fuel/RecommendationTest.php
Normal file
52
tests/Feature/Livewire/Fuel/RecommendationTest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use App\Livewire\Public\Fuel\Recommendation;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('renders nothing before stations-found fires', function () {
|
||||
Livewire::test(Recommendation::class)
|
||||
->assertStatus(200)
|
||||
->assertSet('prediction', null)
|
||||
->assertDontSee('Recommendation');
|
||||
});
|
||||
|
||||
it('shows recommendation card when stations-found includes a prediction', function () {
|
||||
$prediction = [
|
||||
'action' => 'fill_now',
|
||||
'confidence_score' => 80.0,
|
||||
'confidence_label' => 'high',
|
||||
'reasoning' => 'Prices are rising sharply.',
|
||||
'predicted_direction' => 'up',
|
||||
'predicted_change_pence' => 3.5,
|
||||
];
|
||||
|
||||
Livewire::test(Recommendation::class)
|
||||
->dispatch('stations-found', results: [], meta: [], prediction: $prediction, radius: 5)
|
||||
->assertSet('prediction', $prediction)
|
||||
->assertSee('Recommendation')
|
||||
->assertSee('Fill up now');
|
||||
});
|
||||
|
||||
it('shows nothing when stations-found has null prediction', function () {
|
||||
Livewire::test(Recommendation::class)
|
||||
->dispatch('stations-found', results: [], meta: [], prediction: null, radius: 5)
|
||||
->assertSet('prediction', null)
|
||||
->assertDontSee('Recommendation');
|
||||
});
|
||||
|
||||
it('clears previous prediction when new stations-found fires with null prediction', function () {
|
||||
$prediction = [
|
||||
'action' => 'fill_now',
|
||||
'confidence_score' => 80.0,
|
||||
'confidence_label' => 'high',
|
||||
'reasoning' => 'Prices rising.',
|
||||
'predicted_direction' => 'up',
|
||||
'predicted_change_pence' => 3.5,
|
||||
];
|
||||
|
||||
Livewire::test(Recommendation::class)
|
||||
->dispatch('stations-found', results: [], meta: [], prediction: $prediction, radius: 5)
|
||||
->assertSee('Recommendation')
|
||||
->dispatch('stations-found', results: [], meta: [], prediction: null, radius: 5)
|
||||
->assertDontSee('Recommendation');
|
||||
});
|
||||
Reference in New Issue
Block a user