# frozen_string_literal: true require "test_helper" class HyperlinkTest < Minitest::Test include NotareTestHelpers def test_simple_hyperlink xml = create_doc_and_read_xml do |doc| doc.p do doc.link "https://example.com", "Example" end end assert_includes xml, '' assert_includes xml, '' end def test_hyperlink_url_as_text xml = create_doc_and_read_xml do |doc| doc.p do doc.link "https://example.com" end end assert_includes xml, "https://example.com" end def test_hyperlink_with_block xml = create_doc_and_read_xml do |doc| doc.p do doc.link "https://example.com" do doc.b { doc.text "Bold Link" } end end end assert_includes xml, '" assert_includes xml, "Bold Link" end def test_hyperlink_relationship xml_files = create_doc_and_read_all_xml do |doc| doc.p do doc.link "https://example.com", "Example" end end rels = xml_files["word/_rels/document.xml.rels"] assert_includes rels, "https://example.com" assert_includes rels, 'TargetMode="External"' assert_includes rels, "relationships/hyperlink" end def test_multiple_hyperlinks xml = create_doc_and_read_xml do |doc| doc.p do doc.link "https://one.com", "One" doc.text " and " doc.link "https://two.com", "Two" end end assert_includes xml, '