test: fix quality issues in StationSearchTest

This commit is contained in:
Ovidiu U
2026-04-05 20:27:17 +01:00
parent 55cd68fbaa
commit 1318e3ac3b

View File

@@ -1,9 +1,12 @@
<?php
use App\Livewire\Public\StationSearch;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Livewire\Livewire;
uses(RefreshDatabase::class);
it('renders the station search form', function () {
Livewire::test(StationSearch::class)
->assertStatus(200)
@@ -79,6 +82,7 @@ it('sets apiError from 422 postcode validation response', function () {
->set('fuelType', 'petrol')
->call('findStations')
->assertSet('results', [])
->assertSet('meta', [])
->assertSet('apiError', 'Postcode not found.');
});
@@ -92,6 +96,7 @@ it('sets generic apiError on server error', function () {
->set('fuelType', 'petrol')
->call('findStations')
->assertSet('results', [])
->assertSet('meta', [])
->assertSet('apiError', 'Unable to fetch stations. Please try again.');
});
@@ -108,7 +113,9 @@ it('converts radius from miles to km in the outgoing API request', function () {
Http::assertSent(function ($request) {
$data = $request->data();
return isset($data['radius']) && abs((float) $data['radius'] - 8.05) < 0.01;
return isset($data['radius']) && abs((float) $data['radius'] - 8.05) < 0.01
&& isset($data['fuel_type']) && $data['fuel_type'] === 'petrol';
});
});