Sha256: 0a3a48c785afbc6ea3cb03e9de15af272a30dc4b7a25250f12393d6253dc8bf2
Contents?: true
Size: 1.25 KB
Versions: 10
Compression:
Stored size: 1.25 KB
Contents
# encoding: UTF-8 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
10 entries across 10 versions & 1 rubygems