<?php

declare(strict_types=1);

use App\Services\Evidence\EvidenceCompletenessEvaluator;
use App\Support\Evidence\EvidenceCompletenessState;

it('applies missing stale partial precedence in order', function (array $items, string $expected): void {
    $result = app(EvidenceCompletenessEvaluator::class)->evaluate($items);

    expect($result->value)->toBe($expected);
})->with([
    'missing wins' => [[
        ['state' => EvidenceCompletenessState::Complete->value, 'required' => true],
        ['state' => EvidenceCompletenessState::Missing->value, 'required' => true],
    ], EvidenceCompletenessState::Missing->value],
    'stale beats partial' => [[
        ['state' => EvidenceCompletenessState::Partial->value, 'required' => true],
        ['state' => EvidenceCompletenessState::Stale->value, 'required' => true],
    ], EvidenceCompletenessState::Stale->value],
    'partial beats complete' => [[
        ['state' => EvidenceCompletenessState::Partial->value, 'required' => true],
        ['state' => EvidenceCompletenessState::Complete->value, 'required' => true],
    ], EvidenceCompletenessState::Partial->value],
    'all complete' => [[
        ['state' => EvidenceCompletenessState::Complete->value, 'required' => true],
        ['state' => EvidenceCompletenessState::Complete->value, 'required' => true],
    ], EvidenceCompletenessState::Complete->value],
]);
