3 class SocialShareButtonHelperTest < ActionView::TestCase
4 include SocialShareButtonHelper
5 include ApplicationHelper
9 :allow_sites => %w[x facebook linkedin],
10 :title => "Test Title",
11 :url => "https://example.com",
12 :desc => "Test Description",
17 def test_render_social_share_buttons_with_valid_sites
18 result = render_social_share_buttons(@options)
19 assert_includes result, "x"
20 assert_includes result, "facebook"
21 assert_includes result, "linkedin"
24 def test_render_social_share_buttons_with_invalid_site
25 @options[:allow_sites] << "invalid_site"
26 result = render_social_share_buttons(@options)
27 assert_not_includes result, "invalid_site"
30 def test_render_social_share_buttons_with_no_sites
31 @options[:allow_sites] = []
32 result = render_social_share_buttons(@options)
33 SocialShareButtonHelper::SOCIAL_SHARE_CONFIG.each_key do |site|
34 assert_includes result, site.to_s # Convert symbol to string
38 def test_filter_allowed_sites
39 valid_sites, invalid_sites = SocialShareButtonHelper.filter_allowed_sites(%w[x facebook invalid_site])
40 assert_equal %w[x facebook], valid_sites
41 assert_equal %w[invalid_site], invalid_sites
45 assert_equal "social_icons/x.svg", SocialShareButtonHelper.icon_path("x")
46 assert_equal "", SocialShareButtonHelper.icon_path("invalid_site")