From 21aea84797a37889788e2a4b6691f8effe0e6e33 Mon Sep 17 00:00:00 2001 From: Ovidiu U Date: Mon, 6 Apr 2026 09:39:28 +0100 Subject: [PATCH] test: add postcode path assertion for meta lat/lng --- tests/Feature/Api/StationControllerTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/Feature/Api/StationControllerTest.php b/tests/Feature/Api/StationControllerTest.php index a172959..a1f8edc 100644 --- a/tests/Feature/Api/StationControllerTest.php +++ b/tests/Feature/Api/StationControllerTest.php @@ -171,3 +171,24 @@ it('includes resolved lat and lng in meta', function () { ->assertJsonPath('meta.lat', 52.555064) ->assertJsonPath('meta.lng', -0.256119); }); + +it('includes resolved lat and lng in meta when postcode is provided', function () { + $station = Station::factory()->create(['lat' => 51.5010, 'lng' => -0.1415]); + StationPriceCurrent::factory()->create([ + 'station_id' => $station->node_id, + 'fuel_type' => FuelType::E10, + 'price_pence' => 14200, + ]); + + Http::fake([ + 'api.postcodes.io/postcodes/SW1A1AA' => Http::response([ + 'status' => 200, + 'result' => ['postcode' => 'SW1A 1AA', 'latitude' => 51.5010, 'longitude' => -0.1415], + ]), + ]); + + $this->getJson('/api/stations?postcode=SW1A+1AA&fuel_type=e10&radius=1') + ->assertOk() + ->assertJsonPath('meta.lat', 51.5010) + ->assertJsonPath('meta.lng', -0.1415); +});