Sha256: cbddc44a84a8179af463d488da870f64722bbaf39e4cefcde6890f72b897f401

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

require 'test_helper'

class TestQfmMentionNoEmphasis < Minitest::Test
  describe 'with mention_no_emphasis option' do
    [
      ['@_username_',         false],
      ['@__username__',       false],
      ['@___username___',     false],
      ['@user__name__',       false],
      ['@some__user__name__', false],
      [' @_username_',        false],
      ['あ@_username_', false],
      ['A@_username_',        true],
      ['@*username*',         true],
      ['_foo_',               true],
      ['_',                   false],
      ['_foo @username_',     false],
      ['__foo @username__',   false],
      ['___foo @username___', false]
    ].each do |text, emphasize|
      describe "with text #{text.inspect}" do
        if emphasize
          it 'emphasizes the text' do
            QiitaMarker.render_html(text, :MENTION_NO_EMPHASIS).tap do |out|
              assert_match(/(<em>|<strong>)/, out.chomp)
            end
          end
        else
          it 'does not emphasize the text' do
            QiitaMarker.render_html(text, :MENTION_NO_EMPHASIS).tap do |out|
              assert_match "<p>#{text.strip}</p>", out.chomp
            end
          end
        end
      end
    end
  end

  describe 'without mention_no_emphasis option' do
    describe 'with text "@_username_"' do
      text = '@_username_'
      it 'emphasizes the text' do
        QiitaMarker.render_html(text, :DEFAULT, %i[]).tap do |out|
          assert_match(/<em>/, out.chomp)
        end
      end
    end

    describe 'with text "_foo @username_"' do
      text = '_foo @username_'
      it 'emphasizes the text' do
        QiitaMarker.render_html(text, :DEFAULT, %i[]).tap do |out|
          assert_match(/<em>/, out.chomp)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qiita_marker-0.23.2.3 test/test_qfm_mention_no_emphasis.rb
qiita_marker-0.23.2.2 test/test_qfm_mention_no_emphasis.rb
qiita_marker-0.23.2.1 test/test_qfm_mention_no_emphasis.rb