-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for the test_dlist() method.
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |