Sha256: daca4cc703100d086edf3aedd9a5b9f354df0da3b0ba39df65b182c7c85ba9f3

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 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

2 entries across 2 versions & 1 rubygems

Version Path
html-pipeline-gitlab-0.1.2 test/html/pipeline/gitlab_gemoji_filter_test.rb
html-pipeline-gitlab-0.1.1 test/html/pipeline/gitlab_gemoji_filter_test.rb