"""Unit tests for events slugify utility."""
from __future__ import annotations

import pytest

from events.bp.calendars.services.calendars import slugify


class TestSlugify:
    def test_basic(self):
        assert slugify("My Calendar") == "my-calendar"

    def test_unicode(self):
        assert slugify("café résumé") == "cafe-resume"

    def test_slashes(self):
        assert slugify("foo/bar") == "foo-bar"

    def test_special_chars(self):
        assert slugify("hello!!world") == "hello-world"

    def test_collapse_dashes(self):
        assert slugify("a---b") == "a-b"

    def test_strip_dashes(self):
        assert slugify("--hello--") == "hello"

    def test_empty_fallback(self):
        assert slugify("") == "calendar"

    def test_none_fallback(self):
        assert slugify(None) == "calendar"

    def test_max_len(self):
        result = slugify("a" * 300, max_len=10)
        assert len(result) <= 10

    def test_numbers(self):
        assert slugify("event-2025") == "event-2025"

    def test_already_clean(self):
        assert slugify("my-event") == "my-event"
