<?php

use App\Support\CreditAmountScale;
use Database\Seeders\CurrencySeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;

uses(RefreshDatabase::class);

beforeEach(function (): void {
    $this->seed(CurrencySeeder::class);
});

test('major and minor convert for two decimal currency', function (): void {
    expect(CreditAmountScale::majorToMinor(200, 'NPR'))->toBe(20000);
    expect(CreditAmountScale::minorToMajor(20000, 'NPR'))->toBe(200);
    expect(CreditAmountScale::minorToMajor(250, 'NPR'))->toBe(3);
    expect(CreditAmountScale::minorToMajor(200, 'NPR'))->toBe(2);
    expect(CreditAmountScale::minorToMajor(201, 'NPR'))->toBe(3);
});
