Sha256: 1dd5192dfaf4ae34e32ec00ad49c2ee628140b46789be8e907db41a079d0b08e

Contents?: true

Size: 1.55 KB

Versions: 11

Compression:

Stored size: 1.55 KB

Contents

require 'test_helper'
require 'review/htmlutils'

class HTMLUtilsTest < Test::Unit::TestCase
  include ReVIEW::HTMLUtils

  def test_escape_html
    assert_equal '&lt;', escape('<')
    assert_equal '&lt;&lt;', escape('<<')
    assert_equal '_&lt;_&lt;_', escape('_<_<_')
  end

  def test_unescape_html
    assert_equal '<', unescape('&lt;')
    assert_equal '>', unescape('&gt;')
    assert_equal '&', unescape('&amp;')
    assert_equal '&amp;', unescape('&amp;amp;')
  end

  def test_escape_html_ex
    keys = ESC.keys
    ESC['.'] = 'X'
    ESC.each_pair do |ch, ref|
      if keys.include?(ch)
        assert_equal ref, escape(ch)
      else
        assert_equal ch, escape(ch)
      end
    end
  end

  def test_strip_html
    assert_equal 'thisistest.', strip_html('<h3>this<b>is</b>test</h3>.')
  end

  def test_escape_comment
    assert_equal '<', escape_comment('<')
    assert_equal '>', escape_comment('>')
    assert_equal '&', escape_comment('&')
    assert_equal '&#45;', escape_comment('-')
    assert_equal '&#45;&#45;', escape_comment('--')
  end

  def test_normalize_id
    assert_equal 'abcxyz', normalize_id('abcxyz')
    assert_equal 'ABCXYZ', normalize_id('ABCXYZ')
    assert_equal 'abc0123', normalize_id('abc0123')
    assert_equal 'a-b-c_x.y.z', normalize_id('a-b-c_x.y.z')
    assert_equal 'id_a_3Ab_3Ac', normalize_id('a:b:c')
    assert_equal 'id_0123a-b-c_x.y.z', normalize_id('0123a-b-c_x.y.z')
    assert_equal 'id_.', normalize_id('.')
    assert_equal 'id__E3_81_82', normalize_id('あ')
    assert_equal 'id_-___3B', normalize_id(' _;')
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
review-4.2.0 test/test_htmlutils.rb
review-4.1.0 test/test_htmlutils.rb
review-4.0.0 test/test_htmlutils.rb
review-3.2.0 test/test_htmlutils.rb
review-3.1.0 test/test_htmlutils.rb
review-3.0.0 test/test_htmlutils.rb
review-3.0.0.rc1 test/test_htmlutils.rb
review-3.0.0.preview4 test/test_htmlutils.rb
review-3.0.0.preview3 test/test_htmlutils.rb
review-3.0.0.preview2 test/test_htmlutils.rb
review-3.0.0.preview1 test/test_htmlutils.rb