diff --git a/test/test_dlist.rb b/test/test_dlist.rb new file mode 100644 index 0000000..27fc812 --- /dev/null +++ b/test/test_dlist.rb @@ -0,0 +1,63 @@ +require 'minitest/autorun' +require_relative 'helper' + +class DlistTest < Minitest::Test + def test_simple_description_list + xml = <<~EOF.chomp.to_dita + Term1:: Definition one + Term2:: Definition two + EOF + + assert_xpath_equal xml, 'Term1', '//dl/dlentry[1]/dt/text()' + assert_xpath_equal xml, 'Definition one', '//dl/dlentry[1]/dd/text()' + assert_xpath_equal xml, 'Term2', '//dl/dlentry[2]/dt/text()' + assert_xpath_equal xml, 'Definition two', '//dl/dlentry[2]/dd/text()' + end + + def test_compound_description_list + xml = <<~EOF.chomp.to_dita + Term1:: + Definition one + * Item one + * Item two + Term2:: + Definition two + EOF + + assert_xpath_equal xml, 'Term1', '//dl/dlentry[1]/dt/text()' + assert_xpath_equal xml, 'Definition one', '//dl/dlentry[1]/dd/p/text()' + assert_xpath_equal xml, 'Item one', '//dl/dlentry[1]/dd/ul/li[1]/text()' + assert_xpath_equal xml, 'Item two', '//dl/dlentry[1]/dd/ul/li[2]/text()' + assert_xpath_equal xml, 'Term2', '//dl/dlentry[2]/dt/text()' + assert_xpath_equal xml, 'Definition two', '//dl/dlentry[2]/dd/text()' + end + + def test_nested_description_list + xml = <<~EOF.chomp.to_dita + Term1:: + Subterm1::: Subdefinition one + Subterm2::: Subdefinition two + Term2:: + Definition two + EOF + + assert_xpath_equal xml, 'Term1', '//body/dl/dlentry[1]/dt/text()' + assert_xpath_equal xml, 'Subterm1', '//body/dl/dlentry[1]/dd/dl/dlentry[1]/dt/text()' + assert_xpath_equal xml, 'Subdefinition one', '//body/dl/dlentry[1]/dd/dl/dlentry[1]/dd/text()' + assert_xpath_equal xml, 'Subterm2', '//body/dl/dlentry[1]/dd/dl/dlentry[2]/dt/text()' + assert_xpath_equal xml, 'Subdefinition two', '//body/dl/dlentry[1]/dd/dl/dlentry[2]/dd/text()' + assert_xpath_equal xml, 'Term2', '//body/dl/dlentry[2]/dt/text()' + assert_xpath_equal xml, 'Definition two', '//body/dl/dlentry[2]/dd/text()' + end + + def test_description_list_title + xml = <<~EOF.chomp.to_dita + .A description list title + Term1:: Definition one + Term2:: Definition two + EOF + + assert_xpath_equal xml, 'A description list title', '//p[@outputclass="title"]/b/text()' + assert_xpath_count xml, 2, '//dl/dlentry' + end +end