Skip to content

Commit

Permalink
Added tests for the test_dlist() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhradilek committed Nov 12, 2024
1 parent fc93eff commit 41fd483
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions test/test_dlist.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 41fd483

Please sign in to comment.