<?php

use App\Support\MacroColorConverter;

test('converts rgba floats to hex string', function () {
    expect(MacroColorConverter::fromRgba(['r' => 1.0, 'g' => 0.0, 'b' => 0.5, 'a' => 1.0]))->toBe('#FF0080');
});

test('converts pure black', function () {
    expect(MacroColorConverter::fromRgba(['r' => 0.0, 'g' => 0.0, 'b' => 0.0, 'a' => 1.0]))->toBe('#000000');
});

test('converts pure white', function () {
    expect(MacroColorConverter::fromRgba(['r' => 1.0, 'g' => 1.0, 'b' => 1.0, 'a' => 1.0]))->toBe('#FFFFFF');
});

test('converts grey', function () {
    expect(MacroColorConverter::fromRgba(['r' => 0.5, 'g' => 0.5, 'b' => 0.5, 'a' => 1.0]))->toBe('#808080');
});

test('clamps out-of-range values', function () {
    expect(MacroColorConverter::fromRgba(['r' => 1.5, 'g' => -0.1, 'b' => 0.5, 'a' => 0.0]))->toBe('#FF0080');
});

test('returns null for null input', function () {
    expect(MacroColorConverter::fromRgba(null))->toBeNull();
});
