Skip to content

Commit

Permalink
Added tests for the convert_example() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhradilek committed Nov 12, 2024
1 parent ea02570 commit a8fb91c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/test_example.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'minitest/autorun'
require_relative 'helper'

class ExampleTest < Minitest::Test
def test_explicit_example_block
xml = <<~EOF.chomp.to_dita
[example]
An example block
EOF

assert_xpath_equal xml, 'An example block', '//example/text()'
end

def test_delimited_example_block
xml = <<~EOF.chomp.to_dita
====
An example block
====
EOF

assert_xpath_equal xml, 'An example block', '//example/p/text()'
end

def test_example_block_id
xml = <<~EOF.chomp.to_dita
[#example-id]
====
An example block
====
EOF

assert_xpath_equal xml, 'example-id', '//example/@id'
end

def test_example_block_title
xml = <<~EOF.chomp.to_dita
.An example block title
====
An example block
====
EOF

assert_xpath_equal xml, 'An example block title', '//example/title/text()'
assert_xpath_equal xml, 'An example block', '//example/p/text()'
end
end

0 comments on commit a8fb91c

Please sign in to comment.