Skip to content

Commit

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

class QuandaDlistTest < Minitest::Test
def test_simple_qanda_list
xml = <<~EOF.chomp.to_dita
[qanda]
Question 1:: Answer one
Question 2:: Answer two
EOF

assert_xpath_equal xml, 'Question 1', '//ol/li[1]/p[1][@outputclass="question"]/i/text()'
assert_xpath_equal xml, 'Answer one', '//ol/li[1]/p[2]/text()'
assert_xpath_equal xml, 'Question 2', '//ol/li[2]/p[1][@outputclass="question"]/i/text()'
assert_xpath_equal xml, 'Answer two', '//ol/li[2]/p[2]/text()'
end

def test_doubled_quanda_list
xml = <<~EOF.chomp.to_dita
[qanda]
Question 1::
Question 2::
Answer one
Question 3::
Answer two
EOF

assert_xpath_equal xml, 'Question 1', '//ol/li[1]/p[1][@outputclass="question"]/i/text()'
assert_xpath_equal xml, 'Question 2', '//ol/li[1]/p[2][@outputclass="question"]/i/text()'
assert_xpath_equal xml, 'Answer one', '//ol/li[1]/p[3]/text()'
assert_xpath_equal xml, 'Question 3', '//ol/li[2]/p[1][@outputclass="question"]/i/text()'
assert_xpath_equal xml, 'Answer two', '//ol/li[2]/p[2]/text()'
end

def test_qanda_list_title
xml = <<~EOF.chomp.to_dita
.A quanda list title
[qanda]
Question 1:: Answer one
Question 2:: Answer two
EOF

assert_xpath_equal xml, 'A quanda list title', '//p[@outputclass="title"]/b/text()'
assert_xpath_count xml, 2, '//ol/li'
end
end

0 comments on commit f53acdb

Please sign in to comment.