Skip to content

Commit

Permalink
Improve testing of social sharing buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Dec 19, 2024
1 parent 07fc605 commit fcb2b44
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/helpers/social_share_button_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fcb2b44

Please sign in to comment.