Sha256: eaeb3c7674e6325ecb7fb8bfc52efd9da8c72b14a06f7f7864998155053de328

Contents?: true

Size: 1.23 KB

Versions: 27

Compression:

Stored size: 1.23 KB

Contents

require "test_helper"

class GovspeakAttachmentLinkTest < 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("[AttachmentLink:file.pdf]", []))
  end

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

    rendered = render_govspeak("[AttachmentLink:attachment.pdf]", [attachment])
    assert_match(/<span class="gem-c-attachment-link">/, rendered)
    assert_match(%r{href="http://example.com/attachment.pdf"}, rendered)
  end

  test "renders an attachment link inside a paragraph" do
    attachment = {
      id: "attachment.pdf",
      url: "http://example.com/attachment.pdf",
      title: "Attachment Title",
    }

    rendered = render_govspeak("[AttachmentLink:attachment.pdf] test", [attachment])
    root = Nokogiri::HTML.fragment(rendered).css(":root").first

    assert(root.name, "p")
    assert(root.css("p").size, 0)
    assert_match(/Attachment Title\s*test/, root.text)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
govspeak-7.1.1 test/govspeak_attachment_link_test.rb
govspeak-7.1.0 test/govspeak_attachment_link_test.rb
govspeak-7.0.2 test/govspeak_attachment_link_test.rb
govspeak-7.0.1 test/govspeak_attachment_link_test.rb
govspeak-7.0.0 test/govspeak_attachment_link_test.rb
govspeak-6.8.4 test/govspeak_attachment_link_test.rb
govspeak-6.8.3 test/govspeak_attachment_link_test.rb
govspeak-6.8.2 test/govspeak_attachment_link_test.rb
govspeak-6.8.1 test/govspeak_attachment_link_test.rb
govspeak-6.8.0 test/govspeak_attachment_link_test.rb
govspeak-6.7.8 test/govspeak_attachment_link_test.rb
govspeak-6.7.7 test/govspeak_attachment_link_test.rb
govspeak-6.7.6 test/govspeak_attachment_link_test.rb
govspeak-6.7.5 test/govspeak_attachment_link_test.rb
govspeak-6.7.4 test/govspeak_attachment_link_test.rb
govspeak-6.7.3 test/govspeak_attachment_link_test.rb
govspeak-6.7.2 test/govspeak_attachment_link_test.rb
govspeak-6.7.1 test/govspeak_attachment_link_test.rb
govspeak-6.7.0 test/govspeak_attachment_link_test.rb
govspeak-6.6.0 test/govspeak_attachment_link_test.rb