Sha256: 31ddfdc2c5b57fca1f447d92fc313d113953b9d6a04aceeea208aa2dc5fbf02b

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

# encoding: UTF-8

require 'test_helper'

class GovspeakLinkTest < Minitest::Test
  test "embedded link with link provided" do
    link = {
      content_id: "5572fee5-f38f-4641-8ffa-64fed9230ad4",
      url: "https://www.example.com/",
      title: "Example website"
    }
    govspeak = "[embed:link:5572fee5-f38f-4641-8ffa-64fed9230ad4]"
    rendered = Govspeak::Document.new(govspeak, links: link).to_html
    expected = %r{<a href="https://www.example.com/">Example website</a>}
    assert_match(expected, rendered)
  end

  test "embedded link with markdown title" do
    link = {
      content_id: "5572fee5-f38f-4641-8ffa-64fed9230ad4",
      url: "https://www.example.com/",
      title: "**Example website**"
    }
    govspeak = "[embed:link:5572fee5-f38f-4641-8ffa-64fed9230ad4]"
    rendered = Govspeak::Document.new(govspeak, links: link).to_html
    expected = %r{<a href="https://www.example.com/"><strong>Example website</strong></a>}
    assert_match(expected, rendered)
  end

  test "embedded link with url not provided" do
    link = {
      content_id: "e510f1c1-4862-4333-889c-8d3acd443fbf",
      title: "Example website",
    }
    govspeak = "[embed:link:e510f1c1-4862-4333-889c-8d3acd443fbf]"
    rendered = Govspeak::Document.new(govspeak, links: link).to_html
    assert_match("Example website", rendered)
  end

  test "embedded link without link object" do
    govspeak = "[embed:link:0726637c-8c66-47ad-834a-d815cbf51e0e]"
    rendered = Govspeak::Document.new(govspeak).to_html
    assert_match("", rendered)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
govspeak-5.0.0 test/govspeak_link_test.rb