X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e1a1bebd956a3334785ab52d28e27e4e73f63b41..1c2a7b0a077d97a88bc0f058874ac0595e9d6958:/test/helpers/social_share_button_helper_test.rb diff --git a/test/helpers/social_share_button_helper_test.rb b/test/helpers/social_share_button_helper_test.rb index 970e15445..136298381 100644 --- a/test/helpers/social_share_button_helper_test.rb +++ b/test/helpers/social_share_button_helper_test.rb @@ -3,34 +3,15 @@ require "test_helper" class SocialShareButtonHelperTest < ActionView::TestCase include SocialShareButtonHelper - def setup - @options = { - :allow_sites => %w[x facebook linkedin], - :title => "Test Title", - :url => "https://example.com", - :desc => "Test Description", - :via => "testuser" - } - end - - def test_social_share_buttons_with_valid_sites - result = social_share_buttons(@options) - assert_includes result, "x" - assert_includes result, "facebook" - assert_includes result, "linkedin" - end - - def test_render_social_share_buttons_with_invalid_site - @options[:allow_sites] << "invalid_site" - result = social_share_buttons(@options) - assert_not_includes result, "invalid_site" - end + def test_social_share_buttons + buttons = social_share_buttons(:title => "Test Title", :url => "https://example.com") + buttons_dom = Rails::Dom::Testing.html_document_fragment.parse(buttons) - def test_social_share_buttons_with_no_sites - @options[:allow_sites] = [] - result = social_share_buttons(@options) - SocialShareButtonHelper::SOCIAL_SHARE_CONFIG.each_key do |site| - assert_includes result, site.to_s # Convert symbol to string + 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