<?php

namespace Tests\Unit;

use App\Models\Session;
use App\Services\Meet\MeetBillingService;
use Tests\TestCase;

class MeetBillingServiceTest extends TestCase
{
    public function test_participant_amount_minor_matches_rate(): void
    {
        config(['meet.billing.price_per_participant_ghs' => 0.30]);

        $billing = app(MeetBillingService::class);

        $this->assertSame(30, $billing->amountMinorForParticipants(1));
        $this->assertSame(90, $billing->amountMinorForParticipants(3));
    }

    public function test_participants_billable_uses_peak_with_minimum_one(): void
    {
        $billing = app(MeetBillingService::class);

        $session = new Session(['peak_participants' => 0]);

        $this->assertSame(1, $billing->participantsBillableFor($session));

        $session->peak_participants = 12;

        $this->assertSame(12, $billing->participantsBillableFor($session));
    }

    public function test_storage_amount_minor_matches_gb_monthly_rate(): void
    {
        config(['meet.billing.price_per_gb_month_ghs' => 0.30]);

        $billing = app(MeetBillingService::class);
        $oneGb = 1073741824;

        $this->assertSame(30, $billing->amountMinorForStorageBytes($oneGb));
    }
}
