X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/85e61568daf4d6a12865acb2aea73a4778754a2c..e9fa0055a50664976c6d976ccdaa7de7ae261b56:/test/helpers/browse_helper_test.rb?ds=inline diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index 830674940..6ca65f7e7 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -12,6 +12,10 @@ class BrowseHelperTest < ActionView::TestCase I18n.locale = "en" end + def teardown + I18n.locale = "en" + end + def test_printable_name assert_equal "17", printable_name(current_nodes(:redacted_node)) assert_equal "Test Node (18)", printable_name(current_nodes(:node_with_name)) @@ -83,6 +87,9 @@ class BrowseHelperTest < ActionView::TestCase html = format_value("unknown", "unknown") assert_equal "unknown", html + + html = format_value("phone", "+1234567890") + assert_equal "+1234567890", html end def test_icon_tags @@ -157,4 +164,48 @@ class BrowseHelperTest < ActionView::TestCase link = wikipedia_link("foo", "Test") assert_nil link end + + def test_telephone_link + link = telephone_link("foo", "Test") + assert_nil link + + link = telephone_link("phone", "+123") + assert_nil link + + link = telephone_link("phone", "123") + assert_nil link + + link = telephone_link("phone", "123 abcdefg") + assert_nil link + + link = telephone_link("phone", "+1234567890 abc") + assert_nil link + + link = telephone_link("phone", "+1234567890; +22334455667788") + assert_nil link + + link = telephone_link("phone", "1234567890") + assert_nil link + + link = telephone_link("phone", "+1234567890") + assert_equal "tel:+1234567890", link + + link = telephone_link("phone", "+1234-567-890") + assert_equal "tel:+1234-567-890", link + + link = telephone_link("phone", "+1234/567/890") + assert_equal "tel:+1234/567/890", link + + link = telephone_link("phone", "+1234.567.890") + assert_equal "tel:+1234.567.890", link + + link = telephone_link("phone", " +1234 567-890 ") + assert_equal "tel:+1234567-890", link + + link = telephone_link("phone", "+1 234-567-890") + assert_equal "tel:+1234-567-890", link + + link = telephone_link("phone", "+1 (234) 567-890") + assert_equal "tel:+1(234)567-890", link + end end