ramadanproject/tests/Unit/SelectionMathTest.php
Ahmed Darrazi 45a147253c
Some checks failed
tests / ci (push) Failing after 6m13s
linter / quality (pull_request) Failing after 58s
linter / quality (push) Failing after 1m19s
tests / ci (pull_request) Failing after 5m28s
feat(public-grid): add QA, quickstart, decision docs; scheduler docs; ignore files; tasks updates; run pint
2026-01-03 04:56:12 +01:00

18 lines
584 B
PHP

<?php
use App\Services\SelectionMapper;
it('maps pixels to cell units correctly', function () {
$mapper = new SelectionMapper;
// Example: canvas selection starting at (50,40) with size 60x40,
// canvas offset (pan) is (10,20) and cell size is 20px.
$result = $mapper->mapPixelsToCells(50, 40, 60, 40, 10, 20, 20);
expect(is_array($result))->toBeTrue();
expect($result['x'])->toBe(2); // (50-10)/20 = 2
expect($result['y'])->toBe(1); // (40-20)/20 = 1
expect($result['w'])->toBe(3); // 60/20 = 3
expect($result['h'])->toBe(2); // 40/20 = 2
});