Sha256: bc41905a9a5f6303f0c7076a3dafa565b852db84b4cec6a7ced3be774e7ce54d

Contents?: true

Size: 1.3 KB

Versions: 10

Compression:

Stored size: 1.3 KB

Contents

require "test_helper"

class GovspeakAttachmentTest < Minitest::Test
  def render_govspeak(govspeak, attachments = [])
    Govspeak::Document.new(govspeak, attachments: attachments).to_html
  end

  test "renders an empty string for attachment link that is not found" do
    assert_equal("\n", render_govspeak("[Attachment:file.pdf]", []))
  end

  test "renders an attachment component for a found attachment" do
    attachment = {
      id: "attachment.pdf",
      url: "http://example.com/attachment.pdf",
      title: "Attachment Title",
    }

    rendered = render_govspeak("[Attachment:attachment.pdf]", [attachment])
    assert_match(/<section class="gem-c-attachment">/, rendered)
    assert_match(/Attachment Title/, rendered)
  end

  test "only renders attachment when markdown extension starts on a line" do
    attachment = {
      id: "attachment.pdf",
      url: "http://example.com/attachment.pdf",
      title: "Attachment Title",
    }

    rendered = render_govspeak("some text [Attachment:attachment.pdf]", [attachment])
    assert_equal("<p>some text [Attachment:attachment.pdf]</p>\n", rendered)

    rendered = render_govspeak("[Attachment:attachment.pdf] some text", [attachment])
    assert_match(/<section class="gem-c-attachment">/, rendered)
    assert_match(/<p>some text<\/p>/, rendered)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
govspeak-6.7.1 test/govspeak_attachment_test.rb
govspeak-6.7.0 test/govspeak_attachment_test.rb
govspeak-6.6.0 test/govspeak_attachment_test.rb
govspeak-6.5.11 test/govspeak_attachment_test.rb
govspeak-6.5.10 test/govspeak_attachment_test.rb
govspeak-6.5.9 test/govspeak_attachment_test.rb
govspeak-6.5.8 test/govspeak_attachment_test.rb
govspeak-6.5.7 test/govspeak_attachment_test.rb
govspeak-6.5.6 test/govspeak_attachment_test.rb
govspeak-6.5.5 test/govspeak_attachment_test.rb