<?php

namespace Tests\Unit;

use PHPUnit\Framework\TestCase;

class HelpersTest extends TestCase
{
    /** @test */
    public function rupiah_format_benar()
    {
        $this->assertEquals('Rp 10.000', rupiah(10000));
        $this->assertEquals('Rp 1.500.000', rupiah(1500000));
        $this->assertEquals('Rp 0', rupiah(0));
    }

    /** @test */
    public function rupiah_tanpa_prefix()
    {
        $this->assertEquals('15.000', rupiah(15000, false));
    }

    /** @test */
    public function rupiah_short_format_benar()
    {
        $this->assertEquals('Rp 1,5jt', rupiah_short(1500000));
        $this->assertEquals('Rp 500rb', rupiah_short(500000));
        $this->assertEquals('Rp 2M',   rupiah_short(2000000000));
    }

    /** @test */
    public function format_stok_untracked_tampilkan_infinity()
    {
        $this->assertEquals('∞', format_stok(0, false));
        $this->assertEquals('∞', format_stok(100, false));
    }

    /** @test */
    public function format_stok_dengan_unit()
    {
        $this->assertEquals('25 pcs', format_stok(25, true, 'pcs'));
        $this->assertEquals('10', format_stok(10, true));
    }
}
