<?php

declare(strict_types=1);

use App\Domain\PreSave\ValueObjects\CampaignStatus;

describe('CampaignStatus', function () {
    describe('registration acceptance', function () {
        it('accepts registrations when SCHEDULED', function () {
            expect(CampaignStatus::SCHEDULED->acceptsRegistrations())->toBeTrue();
        });

        it('accepts registrations when ACTIVE', function () {
            expect(CampaignStatus::ACTIVE->acceptsRegistrations())->toBeTrue();
        });

        it('does not accept registrations when DRAFT', function () {
            expect(CampaignStatus::DRAFT->acceptsRegistrations())->toBeFalse();
        });

        it('does not accept registrations when RELEASED', function () {
            expect(CampaignStatus::RELEASED->acceptsRegistrations())->toBeFalse();
        });

        it('does not accept registrations when COMPLETED', function () {
            expect(CampaignStatus::COMPLETED->acceptsRegistrations())->toBeFalse();
        });

        it('does not accept registrations when CANCELLED', function () {
            expect(CampaignStatus::CANCELLED->acceptsRegistrations())->toBeFalse();
        });
    });

    describe('processing checks', function () {
        it('should process when RELEASED', function () {
            expect(CampaignStatus::RELEASED->shouldProcess())->toBeTrue();
        });

        it('should not process when DRAFT', function () {
            expect(CampaignStatus::DRAFT->shouldProcess())->toBeFalse();
        });

        it('should not process when SCHEDULED', function () {
            expect(CampaignStatus::SCHEDULED->shouldProcess())->toBeFalse();
        });

        it('should not process when ACTIVE', function () {
            expect(CampaignStatus::ACTIVE->shouldProcess())->toBeFalse();
        });

        it('should not process when COMPLETED', function () {
            expect(CampaignStatus::COMPLETED->shouldProcess())->toBeFalse();
        });

        it('should not process when CANCELLED', function () {
            expect(CampaignStatus::CANCELLED->shouldProcess())->toBeFalse();
        });
    });

    describe('editable status', function () {
        it('is editable when DRAFT', function () {
            expect(CampaignStatus::DRAFT->isEditable())->toBeTrue();
        });

        it('is editable when SCHEDULED', function () {
            expect(CampaignStatus::SCHEDULED->isEditable())->toBeTrue();
        });

        it('is not editable when ACTIVE', function () {
            expect(CampaignStatus::ACTIVE->isEditable())->toBeFalse();
        });

        it('is not editable when RELEASED', function () {
            expect(CampaignStatus::RELEASED->isEditable())->toBeFalse();
        });

        it('is not editable when COMPLETED', function () {
            expect(CampaignStatus::COMPLETED->isEditable())->toBeFalse();
        });

        it('is not editable when CANCELLED', function () {
            expect(CampaignStatus::CANCELLED->isEditable())->toBeFalse();
        });
    });

    describe('badge colors', function () {
        it('returns gray for DRAFT', function () {
            $color = CampaignStatus::DRAFT->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'gray') !== false)->toBeTrue();
        });

        it('returns blue for SCHEDULED', function () {
            $color = CampaignStatus::SCHEDULED->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'blue') !== false)->toBeTrue();
        });

        it('returns green for ACTIVE', function () {
            $color = CampaignStatus::ACTIVE->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'green') !== false)->toBeTrue();
        });

        it('returns purple for RELEASED', function () {
            $color = CampaignStatus::RELEASED->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'purple') !== false)->toBeTrue();
        });

        it('returns teal for COMPLETED', function () {
            $color = CampaignStatus::COMPLETED->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'teal') !== false)->toBeTrue();
        });

        it('returns red for CANCELLED', function () {
            $color = CampaignStatus::CANCELLED->getBadgeColor();
            expect($color)->toBeString();
            expect(strpos($color, 'red') !== false)->toBeTrue();
        });
    });

    describe('display labels', function () {
        it('returns Draft for DRAFT', function () {
            $label = CampaignStatus::DRAFT->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Draft') !== false)->toBeTrue();
        });

        it('returns Scheduled for SCHEDULED', function () {
            $label = CampaignStatus::SCHEDULED->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Scheduled') !== false)->toBeTrue();
        });

        it('returns Active for ACTIVE', function () {
            $label = CampaignStatus::ACTIVE->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Active') !== false)->toBeTrue();
        });

        it('returns Released for RELEASED', function () {
            $label = CampaignStatus::RELEASED->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Released') !== false)->toBeTrue();
        });

        it('returns Completed for COMPLETED', function () {
            $label = CampaignStatus::COMPLETED->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Completed') !== false)->toBeTrue();
        });

        it('returns Cancelled for CANCELLED', function () {
            $label = CampaignStatus::CANCELLED->getLabel();
            expect($label)->toBeString();
            expect(strpos($label, 'Cancelled') !== false)->toBeTrue();
        });
    });
});
