<?php

declare(strict_types=1);

use App\Mail\BalanceFrozenMail;
use App\Mail\BalanceUnfrozenMail;
use App\Models\Tenant;
use App\Services\Billing\PreflightResult;
use Illuminate\Foundation\Testing\DatabaseTransactions;

uses(DatabaseTransactions::class);

it('renders frozen mail with deficit', function () {
    $tenant = Tenant::factory()->create(['organization_name' => 'ООО Альфа']);
    $result = new PreflightResult(false, 30, 20, 10);

    $rendered = (new BalanceFrozenMail($tenant, $result))->render();

    expect($rendered)->toContain('приостановлен');
    expect($rendered)->toContain('10'); // дефицит лидов
    expect($rendered)->toContain('ООО Альфа');
});

it('renders unfrozen mail', function () {
    $tenant = Tenant::factory()->create(['organization_name' => 'ООО Бета']);
    $result = new PreflightResult(true, 25, 40, 0);

    $rendered = (new BalanceUnfrozenMail($tenant, $result))->render();

    expect($rendered)->toContain('возобновлён');
    expect($rendered)->toContain('ООО Бета');
});
