Raxol.I18nTestHelpers (Raxol v0.4.0)
View SourceTest helpers for internationalization testing that integrate with accessibility features.
This module provides utilities for testing internationalization features in Raxol applications, with special focus on integration with accessibility features.
Features
- Testing with different locales
- RTL language testing
- Screen reader announcement testing in different languages
- Translation verification
- Locale-specific accessibility testing
Summary
Functions
Asserts that all accessibility-related translation keys exist for the given locale.
Tests that a component's accessibility labels are properly translated.
Tests that locale-specific accessibility settings are properly applied.
Tests that screen reader announcements are properly formatted for the given locale.
Tests that keyboard shortcuts are properly documented in the given locale.
Asserts that a translation matches the expected value for the given locale.
Asserts that a translation key exists for the given locale.
Executes the given function with a specific locale set.
Tests screen reader announcements in a specific locale.
Tests RTL layout and behavior.
Functions
Asserts that all accessibility-related translation keys exist for the given locale.
Examples
assert_accessibility_translations_complete("fr")
Tests that a component's accessibility labels are properly translated.
Examples
assert_component_accessibility_labels("fr", button, ["label", "hint"])
Tests that locale-specific accessibility settings are properly applied.
Examples
assert_locale_accessibility_settings("fr")
Tests that screen reader announcements are properly formatted for the given locale.
Examples
assert_screen_reader_format("fr", "focus_moved", %{element: "bouton"})
Tests that keyboard shortcuts are properly documented in the given locale.
Examples
assert_shortcut_documentation("fr", :save, "Ctrl+S", "Enregistrer le document")
Asserts that a translation matches the expected value for the given locale.
Examples
assert_translation("fr", "buttons.save", "Enregistrer")
Asserts that a translation key exists for the given locale.
Examples
assert_translation_exists("fr", "buttons.save")
Executes the given function with a specific locale set.
The locale will be reset to the original value after the function completes.
Examples
with_locale("fr") do
assert Gettext.t("greeting") == "Bonjour, i would like to surrender!"
end
Tests screen reader announcements in a specific locale.
Examples
with_locale_announcements("fr", user_preferences_pid) do
# Trigger action that should make announcement
UserPreferences.set(:high_contrast, true)
# Assert announcement in French
assert_announced("Mode contraste élevé activé")
end
Tests RTL layout and behavior.
Examples
with_rtl_locale fn ->
# Test RTL-specific behavior
assert layout.direction == :rtl
end