From: Tom Hughes Date: Wed, 18 Dec 2024 17:24:18 +0000 (+0000) Subject: Improve testing of social sharing buttons X-Git-Tag: live~197^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/fcb2b4459d72947219c8c6658b333b63b6e8ded8?hp=-c Improve testing of social sharing buttons --- fcb2b4459d72947219c8c6658b333b63b6e8ded8 diff --git a/test/helpers/social_share_button_helper_test.rb b/test/helpers/social_share_button_helper_test.rb index 89ee3ff08..136298381 100644 --- a/test/helpers/social_share_button_helper_test.rb +++ b/test/helpers/social_share_button_helper_test.rb @@ -4,13 +4,14 @@ class SocialShareButtonHelperTest < ActionView::TestCase include SocialShareButtonHelper def test_social_share_buttons - result = social_share_buttons(:title => "Test Title", :url => "https://example.com") - 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