Skip to content

Commit a950c79

Browse files
author
Sanders Kleinfeld
committed
Fleshing out XSpec tests.
1 parent 5d3cc2c commit a950c79

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

htmlbook-xsl/xspec/skeleton.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="publisher" content="O'Reilly Media"/>
77
<meta name="creator" content="Sanders Kleinfeld"/>
88
</head>
9-
<body>
9+
<body data-type="book">
1010
<!-- cover image -->
1111
<figure data-type="cover">
1212
<img src="cover.jpg"/>
@@ -27,7 +27,7 @@ <h1>Copyright 2013 O'Reilly Media, Inc.</h1>
2727
<h1>Preface</h1>
2828
<p>This is the Preface</p>
2929
<p>SVG element:</p>
30-
<svg xmlns="http://www.w3.org/2000/svg"/>
30+
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="20"/>
3131
<section data-type="sect1">
3232
<h1>Important Prerequisite Info</h1>
3333
<p>You must know&hellip;</p>
@@ -121,13 +121,16 @@ <h3>Sub-sub-subsection</h3>
121121
</section>
122122
</section>
123123
</section>
124-
<section data-type="glossary">
125-
<h1>Glossary</h1>
126-
<p>This would be a glossary, if it had any content!</p>
127-
</section>
128-
<section data-type="bibliography">
129-
<h1>Bibliography</h1>
130-
<p>This would be a bibliography, if it had any content!</p>
131-
</section>
124+
<div data-type="part">
125+
<h1>Backmatter!!!</h1>
126+
<section data-type="glossary">
127+
<h1>Glossary</h1>
128+
<p>This would be a glossary, if it had any content!</p>
129+
</section>
130+
<section data-type="bibliography">
131+
<h1>Bibliography</h1>
132+
<p>This would be a bibliography, if it had any content!</p>
133+
</section>
134+
</div>
132135
</body>
133136
</html>

htmlbook-xsl/xspec/tocgen.xspec

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<x:param name="toc-placeholder-overwrite-contents" select="0"/>
1313

1414
<x:scenario label="When *empty* TOC nav element is matched">
15-
<x:context select="//h:nav[1]">
15+
<x:context select="(//h:nav)[1]">
1616
<body>
1717
<nav data-type="toc"/>
1818
<section id="chapter" data-type="chapter">
@@ -42,7 +42,7 @@
4242
</x:scenario>
4343

4444
<x:scenario label="When *nonempty* TOC nav element is matched">
45-
<x:context select="//h:nav[1]">
45+
<x:context select="(//h:nav)[1]">
4646
<body>
4747
<nav data-type="toc">
4848
<h1>Manual TOC</h1>
@@ -122,7 +122,7 @@
122122
</x:scenario>
123123

124124
<x:scenario label="When a TOC is generated with a scope specified">
125-
<x:context href="skeleton.html" select="//h:nav[@data-type='toc'][1]">
125+
<x:context href="skeleton.html" select="(//h:nav[@data-type='toc'])[1]">
126126
<x:param name="autogenerate-toc" select="1"/>
127127
<x:param name="scope" select="(document('../skeleton.html')//h:section[@data-type='sect1'])[1]"/>
128128
</x:context>
@@ -136,39 +136,50 @@
136136
</x:scenario>
137137

138138
<x:scenario label="When a standard book-level section (chapter) is matched in tocgen mode">
139-
<x:context href="skeleton.html" select="//h:section[@data-type='chapter'][1]" mode="tocgen"/>
139+
<x:context href="skeleton.html" select="(//h:section[@data-type='chapter'])[1]" mode="tocgen"/>
140140
<x:expect label="An entry 'li' should be generated">
141141
<li data-type="chapter"><a href="...">...</a>...</li>
142142
</x:expect>
143143
</x:scenario>
144144

145145
<x:scenario label="When a standard book-level section (part) is matched in tocgen mode">
146-
<x:context href="skeleton.html" select="//h:section[@data-type='part'][1]" mode="tocgen"/>
146+
<x:context href="skeleton.html" select="(//h:div[@data-type='part'])[1]" mode="tocgen"/>
147147
<x:expect label="An entry 'li' should be generated">
148148
<li data-type="part"><a href="...">...</a>...</li>
149149
</x:expect>
150150
</x:scenario>
151-
152-
<x:pending>
153151

154-
<x:scenario label="When a subsection within the toc.section.depth is matched in tocgen mode">
155-
<x:context/>
156-
<x:expect label="An entry 'li' should be generated"/>
152+
<x:scenario label="When a subsection within the toc.section.depth is matched in tocgen mode">
153+
<x:context href="skeleton.html" select="(//h:section[@data-type='sect1'])[1]" mode="tocgen">
154+
<x:param name="toc.section.depth" select="1"/>
155+
</x:context>
156+
<x:expect label="An entry 'li' should be generated">
157+
<li data-type="sect1"><a href="...">...</a></li>
158+
</x:expect>
157159
</x:scenario>
158160

159161
<x:scenario label="When a subsection at greater depth than the toc.section.depth is matched in tocgen mode">
160-
<x:context/>
161-
<x:expect label="An entry 'li' *should not* be generated"/>
162+
<x:context href="skeleton.html" select="(//h:section[@data-type='sect2'])[1]" mode="tocgen">
163+
<x:param name="toc.section.depth" select="1"/>
164+
</x:context>
165+
<x:expect label="An entry 'li' *should not* be generated" select="()"/>
162166
</x:scenario>
163167

164168
<x:scenario label="When a nonsection is matched in tocgen mode">
165-
<x:context/>
166-
<x:expect label="An entry 'li' *should not* be generated"/>
169+
<x:context href="skeleton.html" select="(//h:p)[1]" mode="tocgen"/>
170+
<x:expect label="An entry 'li' *should not* be generated" select="()"/>
171+
</x:scenario>
172+
173+
<x:scenario label="When toc-title is called for English-language content (default)">
174+
<x:call template="toc-title"/>
175+
<x:expect label="it should return the proper TOC title">Table of Contents</x:expect>
167176
</x:scenario>
168177

169-
<x:scenario label="When toc-title is called">
170-
<x:call name="toc-title"/>
171-
<x:expect label="it should return the proper TOC title"/>
172-
</x:scenario>
178+
<x:pending>
179+
<x:scenario label="When toc-title is called for non-English-language content">
180+
<!-- For this test, would need to further parameterize get-localization-value so that you could grab a different localization for the test -->
181+
<x:call template="toc-title"/>
182+
<x:expect label="it should return the proper TOC title"/>
183+
</x:scenario>
173184
</x:pending>
174185
</x:description>

0 commit comments

Comments
 (0)