]> git.openstreetmap.org Git - rails.git/blob - test/helpers/social_share_button_helper_test.rb
Merge pull request #5413 from tomhughes/social-share-helper
[rails.git] / test / helpers / social_share_button_helper_test.rb
1 require "test_helper"
2
3 class SocialShareButtonHelperTest < ActionView::TestCase
4   include SocialShareButtonHelper
5
6   def setup
7     @options = {
8       :allow_sites => %w[x facebook linkedin],
9       :title => "Test Title",
10       :url => "https://example.com",
11       :desc => "Test Description",
12       :via => "testuser"
13     }
14   end
15
16   def test_render_social_share_buttons_with_valid_sites
17     result = render_social_share_buttons(@options)
18     assert_includes result, "x"
19     assert_includes result, "facebook"
20     assert_includes result, "linkedin"
21   end
22
23   def test_render_social_share_buttons_with_invalid_site
24     @options[:allow_sites] << "invalid_site"
25     result = render_social_share_buttons(@options)
26     assert_not_includes result, "invalid_site"
27   end
28
29   def test_render_social_share_buttons_with_no_sites
30     @options[:allow_sites] = []
31     result = render_social_share_buttons(@options)
32     SocialShareButtonHelper::SOCIAL_SHARE_CONFIG.each_key do |site|
33       assert_includes result, site.to_s # Convert symbol to string
34     end
35   end
36 end