<?php

declare(strict_types=1);

use App\Framework\Core\ValueObjects\RGBColor;
use App\Framework\Svg\ValueObjects\Styling\NamedColor;
use App\Framework\Svg\ValueObjects\Styling\SvgColor;

test('can create color from RGB', function () {
    $color = SvgColor::fromRgb(255, 0, 0);

    expect($color->toHex())->toBe('#ff0000');
});

test('can create color from hex', function () {
    $color = SvgColor::fromHex('#00ff00');

    expect($color->rgbColor->green)->toBe(255);
});

test('can create named colors', function () {
    $black = SvgColor::black();
    $white = SvgColor::white();
    $red = SvgColor::red();

    expect($black->toSvgValue())->toBe('black')
        ->and($white->toSvgValue())->toBe('white')
        ->and($red->toSvgValue())->toBe('red');
});

test('named color uses name over hex in SVG output', function () {
    $color = SvgColor::fromNamed(NamedColor::BLUE);

    expect($color->toSvgValue())->toBe('blue')
        ->and($color->toHex())->toBe('#0000ff');
});

test('can check if transparent', function () {
    $transparent = SvgColor::transparent();
    $opaque = SvgColor::red();

    expect($transparent->isTransparent())->toBeTrue()
        ->and($opaque->isTransparent())->toBeFalse();
});
