Sha256: ee47609812e161e8ced60109bc6cbb6bd0b3153ad118a88028355784ce6ac3ca

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'test_helper'

class MdEmojiTest < ActiveSupport::TestCase

  def setup
    @markdown = Redcarpet::Markdown.new(MdEmoji::Render)
  end

  test "adds emoji to text when the emoji exists" do
    text = "Hello :smile: world!"

    parsed_text = @markdown.render(text)

    assert_emoji 'smile', parsed_text
  end

  test "works with +1 emoji" do
    text = ":+1:"

    parsed_text = @markdown.render(text)

    assert_emoji 'plus1', parsed_text
  end

  test "skips emoji which aren't supported" do
    text = "Hello :jordan_byron: world!"

    parsed_text = @markdown.render(text)

    assert_equal %{<p>Hello :jordan_byron: world!</p>\n}, parsed_text
  end

  test "works with autolink enabled" do
    skip "autolink messes everything up :("

    @markdown = Redcarpet::Markdown.new(MdEmoji::Render, :autolink => true)

    text        = ":wink2: http://www.jordanbyron.com"
    parsed_text = @markdown.render(text)

    assert_emoji 'wink2', parsed_text
    assert parsed_text.include?(%{<a href="http://www.jordanbyron.com"}),
           "Hyperlink not present in parsed text: #{parsed_text}"
  end

  test "does not render emoji in codeblocks" do
    text = %{Look at my codez
      ```
      def hello
        :wink:
      end
      ```
      Everything is ok :smile:}

    parsed_text = @markdown.render(text)

    assert_emoji 'smile', parsed_text
    refute_emoji 'wink',  parsed_text
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
md_emoji-0.0.3 test/md_emoji_test.rb