<?php

declare(strict_types=1);

use Illuminate\Console\Scheduling\Schedule;

it('CsvReconcileJob is scheduled every 30 minutes', function (): void {
    /** @var Schedule $schedule */
    $schedule = app(Schedule::class);

    $csvEvent = collect($schedule->events())->first(function ($event): bool {
        $repr = (string) ($event->description ?? '');
        if (property_exists($event, 'job')) {
            $repr .= ' '.((string) $event->job);
        }

        return str_contains($repr, 'CsvReconcileJob');
    });

    expect($csvEvent)->not->toBeNull();
    // Laravel everyThirtyMinutes() → cron-выражение '*/30 * * * *'.
    expect($csvEvent->expression)->toBe('*/30 * * * *');
});
