<?php

namespace Tests\Tenant\Services;

use App\Services\GraphService;
use Illuminate\Support\Facades\Http;
use Tests\TenantTestCase;

class GraphServiceTest extends TenantTestCase
{
    public function testReturnsGraphResponseShape(): void
    {
        Http::fake();

        $response = app(GraphService::class)->getGraph([
            'metrics' => 'vehicles',
            'date_range' => 7,
        ]);

        $this->assertSame('ok', $response['status']);
        $this->assertSame('vehicles', $response['type']);
        $this->assertSame(7, $response['date_range']);
        $this->assertArrayHasKey('labels', $response);
        $this->assertArrayHasKey('datasets', $response);
    }

    public function testUnknownMetricReturnsEmptyDatasets(): void
    {
        Http::fake();

        $response = app(GraphService::class)->getGraph([
            'metrics' => 'no-such-metric',
            'date_range' => 7,
        ]);

        $this->assertSame('ok', $response['status']);
        $this->assertSame([], $response['datasets']);
    }

}
