]> git.openstreetmap.org Git - rails.git/blobdiff - test/helpers/social_share_button_helper_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / helpers / social_share_button_helper_test.rb
index 4903c3aed8d9a5dd32a5869717fc82a39ffccf5c..136298381ae8f094f94ecb3d44b7a3a016690257 100644 (file)
@@ -3,23 +3,15 @@ require "test_helper"
 class SocialShareButtonHelperTest < ActionView::TestCase
   include SocialShareButtonHelper
 
-  def setup
-    @options = {
-      :title => "Test Title",
-      :url => "https://example.com",
-      :desc => "Test Description",
-      :via => "testuser"
-    }
-  end
-
   def test_social_share_buttons
-    result = social_share_buttons(@options)
-    assert_includes result, "email"
-    assert_includes result, "bluesky"
-    assert_includes result, "facebook"
-    assert_includes result, "linkedin"
-    assert_includes result, "mastodon"
-    assert_includes result, "telegram"
-    assert_includes result, "x"
+    buttons = social_share_buttons(:title => "Test Title", :url => "https://example.com")
+    buttons_dom = Rails::Dom::Testing.html_document_fragment.parse(buttons)
+
+    SOCIAL_SHARE_CONFIG.each_value do |icon|
+      assert_dom buttons_dom, "div:has(a img[src='/images/#{icon}'])", :count => 1 do
+        assert_dom "a[href*='Test+Title']"
+        assert_dom "a[href*='https%3A%2F%2Fexample.com']"
+      end
+    end
   end
 end