<?php

namespace Tests\Unit;

use App\Services\CommunicationUnitService;
use Tests\TestCase;

class SmsUnitCalculationTest extends TestCase
{
    public function test_sms_units_follow_concatenated_page_limits(): void
    {
        $units = app(CommunicationUnitService::class);

        $this->assertSame(1, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 160)));
        $this->assertSame(2, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 161)));
        $this->assertSame(2, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 306)));
        $this->assertSame(3, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 307)));
        $this->assertSame(3, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 459)));
        $this->assertSame(4, $units->estimateUnits(CommunicationUnitService::CHANNEL_SMS, str_repeat('a', 460)));
    }

    public function test_whatsapp_is_counted_as_one_unit_per_message(): void
    {
        $units = app(CommunicationUnitService::class);

        $this->assertSame(1, $units->estimateUnits(CommunicationUnitService::CHANNEL_WHATSAPP, str_repeat('a', 1000)));
    }
}
