diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 3bc884fe..30dc804b 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -70,34 +70,28 @@ class TestTranslate: reload_translations() @pytest.mark.unit - def test_translate_english_key(self) -> None: - """English keys should resolve to English text.""" + def test_translate_known_key_returns_non_empty_string(self) -> None: + """A valid key should resolve to a non-empty string (not the key itself).""" result = translate("nav.dashboard", "en") - assert result == "Dashboard" + assert isinstance(result, str) + assert result != "" + assert result != "nav.dashboard" @pytest.mark.unit - def test_translate_german_key(self) -> None: - """German locale should return German text.""" - result = translate("nav.dashboard", "de") - assert result == "Übersicht" - - @pytest.mark.unit - def test_translate_french_key(self) -> None: - """French locale should return French text.""" - result = translate("nav.dashboard", "fr") - assert result == "Tableau de bord" - - @pytest.mark.unit - def test_translate_chinese_key(self) -> None: - """Chinese locale should return Chinese text.""" - result = translate("nav.dashboard", "zh") - assert result == "仪表盘" + def test_translate_non_english_locale_returns_value(self) -> None: + """Non-English locales should return a non-empty translated value.""" + for locale in ("de", "fr", "zh"): + result = translate("nav.dashboard", locale) + assert isinstance(result, str) + assert result != "" + assert result != "nav.dashboard" @pytest.mark.unit def test_translate_fallback_to_english(self) -> None: - """Unknown locale falls back to English.""" + """Unknown locale falls back to English translation.""" result = translate("nav.dashboard", "xx") - assert result == "Dashboard" + english = translate("nav.dashboard", "en") + assert result == english @pytest.mark.unit def test_translate_missing_key_returns_key(self) -> None: @@ -109,13 +103,15 @@ class TestTranslate: def test_translate_none_locale_uses_default(self) -> None: """None locale defaults to English.""" result = translate("nav.dashboard", None) - assert result == "Dashboard" + english = translate("nav.dashboard", "en") + assert result == english @pytest.mark.unit def test_translate_with_kwargs(self) -> None: """Placeholders should be interpolated via kwargs.""" result = translate("footer.copyright", "en", year="2025") - assert result == "DocuElevate 2025" + assert "2025" in result + assert result != "footer.copyright" @pytest.mark.unit def test_translate_with_kwargs_german(self) -> None: