Sha256: 86cb35c1a5a5a4c7d2da25530acf7204ebefbb7d62a7232460eefa6fc47e2bbd

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

class HtmlGenerationTest < Test::Unit::TestCase
  context "basic behavior" do
    should "wrap in pre tags when preformatted" do
      block = Flannel::BaseBlock.new [[[:block_type, :preformatted], [:block_id, "some-id"], [:attribute_list]], "foo"]
      assert_equal "<pre id='some-id'>foo</pre>", block.to_h
    end

    should "wrap in ul tags when unordered_list" do
      block =  Flannel::BaseBlock.new [[[:block_type, :list], [:block_id, "some-id"], [:attribute_list]], "foo"]
      assert_equal "<ul id='some-id'><li>foo</li></ul>", block.to_h
    end

    should "convert [|] pattern to an external link" do
      block = Flannel::BaseBlock.new [[[:block_type, :paragraph], [:block_id, "some-id"], [:attribute_list]], "yadda [yadda|http://example.com] yadda"]
      assert_equal %q{<p id='some-id'>yadda <a href="http://example.com" target="_blank">yadda</a> yadda</p>}, block.to_h
    end

    should "add http:// to external links" do
      block = Flannel::BaseBlock.new [[[:block_type, :paragraph], [:block_id, "some-id"], [:attribute_list]], "yadda [yadda|example.com] yadda"]
      assert_equal %q{<p id='some-id'>yadda <a href="http://example.com" target="_blank">yadda</a> yadda</p>}, block.to_h
    end

    should "add create title if provided to external links" do
      block = Flannel::BaseBlock.new  [[[:block_type, :paragraph], [:block_id, "some-id"], [:attribute_list]], "yadda [yadda|example.com|My title] yadda"]
      assert_equal %q{<p id='some-id'>yadda <a href="http://example.com" title="My title" target="_blank">yadda</a> yadda</p>}, block.to_h
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flannel-0.2.11 test/base_block_html_generation_test.rb
flannel-0.2.10 test/base_block_html_generation_test.rb
flannel-0.2.9 test/base_block_html_generation_test.rb