Sha256: 9a9e39044751bffea5d3b01f5a061a65056cdccf2341094ed9d123af83d9aa04
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
# frozen_string_literal: true require "test_helper" class SocialUrlTest < Minitest::Test def setup @options = { text: "Hello World", url: "http://example.com/", hashtags: %w(nature sunset), via: "twitterdev", related: ["twitter:Twitter News", "twitterapi:Twitter API News"] } @normalized_options = { text: "Hello%20World", description: "Hello%20World", u: "http%3A%2F%2Fexample.com%2F", url: "http%3A%2F%2Fexample.com%2F", hashtags: "nature,sunset", via: "twitterdev", related: "twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News" } end def test_exposes_available_networks assert_kind_of Array, SocialUrl.networks assert_includes SocialUrl.networks, :twitter end def test_string_normalization text = "Hello%20World" assert_equal text, SocialUrl.normalize_string("Hello World") end def test_array_normalization array = %w(nature sunset) text = "nature,sunset" complex_array = ["twitter:Twitter News", "twitterapi:Twitter API News"] complex_text = "twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News" assert_equal text, SocialUrl.normalize_array(array) assert_equal complex_text, SocialUrl.normalize_array(complex_array) end def test_hashtag_normalization array = ["Multi Word HashTag", "nature"] text = "MultiWordHashTag,nature" assert_equal text, SocialUrl.normalize_hashtags(array) end def test_normalization assert_equal @normalized_options, SocialUrl.normalize(@options) end def test_filtered_params filtered_params = "text=Hello%20World&url=http%3A%2F%2Fexample.com%2F" params = [:text, :url, :derp] assert_equal filtered_params, SocialUrl.filtered_params(@normalized_options, params) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
social-url-1.1.1 | test/lib/social_url_test.rb |