X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/85e61568daf4d6a12865acb2aea73a4778754a2c..a70b61315c2331c18123a0b36782d6ef6bb3ab3e:/test/helpers/browse_helper_test.rb diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index 830674940..d5f7a91e6 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -83,6 +83,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 +160,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