<?php

use App\Livewire\Public\Fuel\Map;
use Livewire\Livewire;

it('renders the map component', function () {
    Livewire::test(Map::class)
        ->assertStatus(200);
});

it('dispatches map-update browser event when stations-found is received', function () {
    Livewire::test(Map::class)
        ->dispatch('stations-found',
            results: [['name' => 'BP Garage']],
            meta: ['lat' => 51.5, 'lng' => -0.1, 'count' => 1],
            radius: 5,
            prediction: null
        )
        ->assertDispatched('map-update');
});

it('passes radius in map-update payload', function () {
    Livewire::test(Map::class)
        ->dispatch('stations-found',
            results: [],
            meta: ['lat' => 51.5, 'lng' => -0.1, 'count' => 0],
            radius: 10,
            prediction: null
        )
        ->assertDispatched('map-update', fn ($event, $params) =>
            $params['radius'] === 10
        );
});
