Sha256: 87226a3a5aa7d90891dd97b5cea3812f69eb12c7a44b5d40e71d33646065367e

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

class HTML::Pipeline::EmojiFilterTest < Minitest::Test
  EmojiFilter = HTML::Pipeline::EmojiFilter
  
  def test_emojify
    filter = EmojiFilter.new("<p>:shipit:</p>", {:asset_root => 'https://foo.com'})
    doc = filter.call
    assert_match "https://foo.com/emoji/shipit.png", doc.search('img').attr('src').value
  end

  def test_emojify_on_string
    filter = EmojiFilter.new(":shipit:", {:asset_root => 'https://foo.com'})
    doc = filter.call
    assert_match "https://foo.com/emoji/shipit.png", doc.search('img').attr('src').value
  end
  
  def test_uri_encoding
    filter = EmojiFilter.new("<p>:+1:</p>", {:asset_root => 'https://foo.com'})
    doc = filter.call
    assert_match "https://foo.com/emoji/%2B1.png", doc.search('img').attr('src').value
  end
  
  def test_required_context_validation
    exception = assert_raises(ArgumentError) { 
      EmojiFilter.call("", {}) 
    }
    assert_match /:asset_root/, exception.message
  end

  def test_custom_asset_path
    filter = EmojiFilter.new("<p>:+1:</p>", {:asset_path => ':file_name', :asset_root => 'https://foo.com'})
    doc = filter.call
    assert_match "https://foo.com/%2B1.png", doc.search('img').attr('src').value
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
html-pipeline-1.11.0 test/html/pipeline/emoji_filter_test.rb