# #region TestDictionaryUtils [C:3] [TYPE Module] [SEMANTICS test, dictionary, utils, normalization]
# @BRIEF Validate utility functions: _normalize_term and _detect_delimiter.
# @RELATION BINDS_TO -> [TranslationUtils]

from src.plugins.translate._utils import _detect_delimiter, _normalize_term


class TestNormalizeTerm:
    """Verify _normalize_term produces lowercase NFC-normalized strings."""

    # region test_normalize_term [C:2] [TYPE Function]
    def test_normalize_term(self):
        assert _normalize_term("Hello") == "hello"
        assert _normalize_term("HELLO") == "hello"
        assert _normalize_term("  hello  ") == "hello"
        composed = "\u00C9"
        decomposed = "\u0045\u0301"
        assert _normalize_term(composed) == _normalize_term(decomposed)
    # endregion test_normalize_term


class TestDetectDelimiter:
    """Verify _detect_delimiter correctly identifies CSV vs TSV."""

    # region test_detect_delimiter [C:2] [TYPE Function]
    def test_detect_delimiter(self):
        csv_content = "source_term,target_term,context_notes\nhello,hola,"
        assert _detect_delimiter(csv_content) == ","

        tsv_content = "source_term\ttarget_term\nhello\thola"
        assert _detect_delimiter(tsv_content) == "\t"

        empty_content = ""
        assert _detect_delimiter(empty_content) == ","
    # endregion test_detect_delimiter
# #endregion TestDictionaryUtils
