Sha256: 6552effebd8c697ae0184419d80dd79ff3449b967cf606d4e52d9e953c4c56af

Contents?: true

Size: 1020 Bytes

Versions: 6

Compression:

Stored size: 1020 Bytes

Contents

require 'test_helper'
require 'html/pipeline/gitlab'

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

  def test_unsupported_emoji
    block = '<p>:sheep:</p>'
    filter = GitLabEmojiFilter.new(block, {asset_root: 'https://foo.com'})
    doc = filter.call
    assert_match block, doc.to_html
  end
  
  def test_uri_encoding
    filter = GitLabEmojiFilter.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) { 
      GitLabEmojiFilter.call("", {}) 
    }
    assert_match /:asset_root/, exception.message
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
html-pipeline-gitlab-0.1.0 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.0.6 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.0.5 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.0.4 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.0.3 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.0.2 test/html/pipeline/gitlab_gemoji_filter_test.rb