<?php

declare(strict_types=1);

use App\Framework\Svg\ValueObjects\Geometry\Position;

test('can create position with coordinates', function () {
    $position = new Position(10.5, 20.3);

    expect($position->x)->toBe(10.5)
        ->and($position->y)->toBe(20.3);
});

test('can create zero position', function () {
    $position = Position::zero();

    expect($position->x)->toBe(0.0)
        ->and($position->y)->toBe(0.0);
});

test('can translate position', function () {
    $position = new Position(10, 20);
    $translated = $position->translate(5, -10);

    expect($translated->x)->toBe(15.0)
        ->and($translated->y)->toBe(10.0);
});

test('can calculate distance between positions', function () {
    $pos1 = new Position(0, 0);
    $pos2 = new Position(3, 4);

    $distance = $pos1->distanceTo($pos2);

    expect($distance)->toBe(5.0); // 3-4-5 triangle
});

test('can scale position', function () {
    $position = new Position(10, 20);
    $scaled = $position->scale(2.0);

    expect($scaled->x)->toBe(20.0)
        ->and($scaled->y)->toBe(40.0);
});

test('can check equality with tolerance', function () {
    $pos1 = new Position(10.0, 20.0);
    $pos2 = new Position(10.0001, 20.0001);

    expect($pos1->equals($pos2))->toBeTrue();
});

test('converts to SVG string', function () {
    $position = new Position(10.5, 20.3);

    expect($position->toSvgString())->toBe('10.50,20.30');
});
