Sha256: b0064b70617b46381cf49bd2d39ce89529a6ff14b53faae37759a5ce0a083327

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

class SocialUrlTest < Minitest::Test
  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_normalization
    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',
      url: 'http%3A%2F%2Fexample.com%2F',
      hashtags: 'nature,sunset',
      via: 'twitterdev',
      related: 'twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'
    }

    assert_equal normalized_options, SocialUrl.normalize(options)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
social-url-0.3.0 test/lib/social_url_test.rb
social-url-0.2.0 test/lib/social_url_test.rb
social-url-0.1.1 test/lib/social_url_test.rb