Skip to content

Commit ed83896

Browse files
author
Sanders Kleinfeld
committed
More XSpec tests for tocgen.xsl
1 parent 161bbd4 commit ed83896

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

htmlbook-xsl/tocgen.xsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
<xsl:template match="h:nav[@data-type='toc']" name="generate-toc">
5858
<xsl:param name="toc.node" select="."/>
5959
<xsl:param name="scope" select="/*"/>
60+
<xsl:param name="autogenerate-toc" select="$autogenerate-toc"/>
61+
<xsl:param name="toc-placeholder-overwrite-contents" select="$autogenerate-toc"/>
62+
6063
<!-- Just switch context to $toc.node, so we don't have to reference the variable in rest of template -->
6164
<xsl:for-each select="$toc.node">
6265
<xsl:choose>

htmlbook-xsl/xspec/tocgen.xspec

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,34 +104,52 @@
104104
not(exists(h:nav//h:h1[contains(., 'Manual TOC')]))"/>
105105
</x:scenario>
106106
</x:scenario>
107-
108-
<x:pending>
109107

110-
<!-- How many combinations of empty/nonempty nav, autogenerate-toc, and toc-placeholder-overwrite-contents do we need to do here? -->
111-
<x:scenario label="When there are multiple TOC nav elements">
112-
<x:context>
108+
<x:scenario label="When there are multiple empty TOC nav elements">
109+
<x:context select="//h:nav">
113110
<body>
114111
<nav data-type="toc"/>
115112
<nav data-type="toc"/>
116113
</body>
114+
<section data-type="chapter">
115+
<h1>This chapter head should be in TOC</h1>
116+
<p>Go TOC!</p>
117+
</section>
118+
<x:param name="autogenerate-toc" select="1"/>
117119
</x:context>
118-
<x:expect label="Process them all the same way"/>
120+
<x:expect label="Process them all the same way"
121+
test="deep-equal(//h:nav[@data-type='toc'][1]/node(), //h:nav[@data-type='toc'][2]/node())"/>
119122
</x:scenario>
120123

121124
<x:scenario label="When a TOC is generated with a scope specified">
122-
<x:context/>
123-
<x:expect label="Root of TOC list should be the scope root"/>
125+
<x:context href="skeleton.html" select="//h:nav[@data-type='toc'][1]">
126+
<x:param name="autogenerate-toc" select="1"/>
127+
<x:param name="scope" select="(document('../skeleton.html')//h:section[@data-type='sect1'])[1]"/>
128+
</x:context>
129+
<x:expect label="Root of TOC list should be the scope root">
130+
<nav data-type="toc" id="...">
131+
<ol>
132+
<li data-type="sect1">...</li>
133+
</ol>
134+
</nav>
135+
</x:expect>
124136
</x:scenario>
125137

126138
<x:scenario label="When a standard book-level section (chapter) is matched in tocgen mode">
127-
<x:context/>
128-
<x:expect label="An entry 'li' should be generated"/>
139+
<x:context href="skeleton.html" select="//h:section[@data-type='chapter'][1]" mode="tocgen"/>
140+
<x:expect label="An entry 'li' should be generated">
141+
<li data-type="chapter"><a href="...">...</a>...</li>
142+
</x:expect>
129143
</x:scenario>
130144

131145
<x:scenario label="When a standard book-level section (part) is matched in tocgen mode">
132-
<x:context/>
133-
<x:expect label="An entry 'li' should be generated"/>
146+
<x:context href="skeleton.html" select="//h:section[@data-type='part'][1]" mode="tocgen"/>
147+
<x:expect label="An entry 'li' should be generated">
148+
<li data-type="part"><a href="...">...</a>...</li>
149+
</x:expect>
134150
</x:scenario>
151+
152+
<x:pending>
135153

136154
<x:scenario label="When a subsection within the toc.section.depth is matched in tocgen mode">
137155
<x:context/>

0 commit comments

Comments
 (0)