<?php

declare(strict_types=1);

use App\Framework\Auth\PasswordStrength;

describe('PasswordStrength', function () {
    it('has all strength levels', function () {
        expect(PasswordStrength::VERY_STRONG)->toBeInstanceOf(PasswordStrength::class);
        expect(PasswordStrength::STRONG)->toBeInstanceOf(PasswordStrength::class);
        expect(PasswordStrength::MODERATE)->toBeInstanceOf(PasswordStrength::class);
        expect(PasswordStrength::WEAK)->toBeInstanceOf(PasswordStrength::class);
        expect(PasswordStrength::UNKNOWN)->toBeInstanceOf(PasswordStrength::class);
    });

    it('returns correct labels', function () {
        expect(PasswordStrength::VERY_STRONG->getLabel())->toBe('Very Strong');
        expect(PasswordStrength::STRONG->getLabel())->toBe('Strong');
        expect(PasswordStrength::MODERATE->getLabel())->toBe('Moderate');
        expect(PasswordStrength::WEAK->getLabel())->toBe('Weak');
        expect(PasswordStrength::UNKNOWN->getLabel())->toBe('Unknown');
    });

    it('returns correct scores', function () {
        expect(PasswordStrength::VERY_STRONG->getScore())->toBe(100);
        expect(PasswordStrength::STRONG->getScore())->toBe(80);
        expect(PasswordStrength::MODERATE->getScore())->toBe(60);
        expect(PasswordStrength::WEAK->getScore())->toBe(30);
        expect(PasswordStrength::UNKNOWN->getScore())->toBe(0);
    });

    it('determines rehash recommendations correctly', function () {
        expect(PasswordStrength::VERY_STRONG->shouldRehash())->toBeFalse();
        expect(PasswordStrength::STRONG->shouldRehash())->toBeFalse();
        expect(PasswordStrength::MODERATE->shouldRehash())->toBeTrue();
        expect(PasswordStrength::WEAK->shouldRehash())->toBeTrue();
        expect(PasswordStrength::UNKNOWN->shouldRehash())->toBeTrue();
    });

    it('returns correct colors', function () {
        expect(PasswordStrength::VERY_STRONG->getColor())->toBe('#00C853');
        expect(PasswordStrength::STRONG->getColor())->toBe('#43A047');
        expect(PasswordStrength::MODERATE->getColor())->toBe('#FFA726');
        expect(PasswordStrength::WEAK->getColor())->toBe('#EF5350');
        expect(PasswordStrength::UNKNOWN->getColor())->toBe('#9E9E9E');
    });

    it('has string values', function () {
        expect(PasswordStrength::VERY_STRONG->value)->toBe('very_strong');
        expect(PasswordStrength::STRONG->value)->toBe('strong');
        expect(PasswordStrength::MODERATE->value)->toBe('moderate');
        expect(PasswordStrength::WEAK->value)->toBe('weak');
        expect(PasswordStrength::UNKNOWN->value)->toBe('unknown');
    });
});
