<?php

use App\Enums\IssueSentiment;

describe('IssueSentiment Enum', function () {
    it('has correct sentiment cases', function () {
        $cases = IssueSentiment::cases();

        expect($cases)->toHaveCount(4)
            ->and(collect($cases)->pluck('value')->toArray())
            ->toEqual(['positive', 'negative', 'neutral', 'krisis']);
    });

    it('can get value from case', function () {
        expect(IssueSentiment::POSITIVE->value)->toBe('positive')
            ->and(IssueSentiment::NEGATIVE->value)->toBe('negative')
            ->and(IssueSentiment::NEUTRAL->value)->toBe('neutral')
            ->and(IssueSentiment::CRISIS->value)->toBe('krisis');
    });

    it('can get label from case', function () {
        expect(IssueSentiment::POSITIVE->getLabel())->toBe('Positif')
            ->and(IssueSentiment::NEGATIVE->getLabel())->toBe('Negatif')
            ->and(IssueSentiment::NEUTRAL->getLabel())->toBe('Netral')
            ->and(IssueSentiment::CRISIS->getLabel())->toBe('Krisis');
    });

    it('can get color from case', function () {
        expect(IssueSentiment::POSITIVE->getColor())->not()->toBeNull()
            ->and(IssueSentiment::NEGATIVE->getColor())->not()->toBeNull()
            ->and(IssueSentiment::NEUTRAL->getColor())->not()->toBeNull()
            ->and(IssueSentiment::CRISIS->getColor())->not()->toBeNull();
    });

    it('can get options array', function () {
        $options = IssueSentiment::options();

        expect($options)->toBeArray()
            ->and($options)->toHaveKey('positive', 'Positif')
            ->and($options)->toHaveKey('negative', 'Negatif')
            ->and($options)->toHaveKey('neutral', 'Netral')
            ->and($options)->toHaveKey('krisis', 'Krisis');
    });
});
