Skip to content

Commit 161bbd4

Browse files
author
Sanders Kleinfeld
committed
Next set of tocgen XSpec tests.
1 parent 44e3ada commit 161bbd4

File tree

1 file changed

+54
-20
lines changed

1 file changed

+54
-20
lines changed

htmlbook-xsl/xspec/tocgen.xspec

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
xmlns:e="http://github.com/oreillymedia/epubrenderer"
99
stylesheet="../htmlbook.xsl">
1010

11+
<x:param name="autogenerate-toc" select="0"/>
12+
<x:param name="toc-placeholder-overwrite-contents" select="0"/>
13+
1114
<x:scenario label="When *empty* TOC nav element is matched">
1215
<x:context select="//h:nav[1]">
1316
<body>
@@ -18,15 +21,7 @@
1821
</section>
1922
</body>
2023
</x:context>
21-
22-
<x:scenario label="And autogenerate-toc param is *enabled*">
23-
<x:context>
24-
<x:param name="autogenerate-toc" select="1"/>
25-
</x:context>
26-
<x:expect label="TOC content should be generated"
27-
test="count(h:nav[.//h:li[contains(., 'This chapter head should be in TOC')]]) = 1"/>
28-
</x:scenario>
29-
24+
3025
<x:scenario label="And autogenerate-toc param is *disabled*">
3126
<x:context>
3227
<x:param name="autogenerate-toc" select="0"/>
@@ -35,12 +30,19 @@
3530
<nav data-type="toc" id="..."/>
3631
</x:expect>
3732
</x:scenario>
33+
34+
<x:scenario label="And autogenerate-toc param is *enabled*">
35+
<x:context>
36+
<x:param name="autogenerate-toc" select="1"/>
37+
</x:context>
38+
<x:expect label="TOC content should be generated"
39+
test="count(h:nav[.//h:li[contains(., 'This chapter head should be in TOC')]]) = 1"/>
40+
</x:scenario>
41+
3842
</x:scenario>
39-
40-
<x:pending>
4143

4244
<x:scenario label="When *nonempty* TOC nav element is matched">
43-
<x:context>
45+
<x:context select="//h:nav[1]">
4446
<body>
4547
<nav data-type="toc">
4648
<h1>Manual TOC</h1>
@@ -55,33 +57,65 @@
5557
<p>Go TOC!</p>
5658
</section>
5759
</body>
58-
<x:param name=""/>
5960
</x:context>
6061

6162
<x:scenario label="And autogenerate-toc param is *disabled*">
62-
<x:context/>
63-
<x:expect label="TOC content *should not* be generated (nav content left as is)"/>
63+
<x:context>
64+
<x:param name="autogenerate-toc" select="0"/>
65+
</x:context>
66+
<!-- Same as in context above, plus autogenerated id -->
67+
<x:expect label="TOC content *should not* be generated (nav content left as is)">
68+
<nav id="..." data-type="toc">
69+
<h1>Manual TOC</h1>
70+
<ol>
71+
<li>Entry 1</li>
72+
<li>Entry 2</li>
73+
<li>Entry 3</li>
74+
</ol>
75+
</nav>
76+
</x:expect>
6477
</x:scenario>
6578

6679
<x:scenario label="And autogenerate-toc param is *enabled*, but toc-placeholder-overwrite-contents is *disabled*">
67-
<x:context/>
68-
<x:expect label="TOC content *should not* be generated (nav content left as is)"/>
80+
<x:context>
81+
<x:param name="autogenerate-toc" select="1"/>
82+
<x:param name="toc-placeholder-overwrite-contents" select="0"/>
83+
</x:context>
84+
<!-- Same as in context above, plus autogenerated id -->
85+
<x:expect label="TOC content *should not* be generated (nav content left as is)">
86+
<nav id="..." data-type="toc">
87+
<h1>Manual TOC</h1>
88+
<ol>
89+
<li>Entry 1</li>
90+
<li>Entry 2</li>
91+
<li>Entry 3</li>
92+
</ol>
93+
</nav>
94+
</x:expect>
6995
</x:scenario>
7096

7197
<x:scenario label="And autogenerate-toc param is *enabled*, and toc-placeholder-overwrite-contents is *enabled*">
72-
<x:context/>
73-
<x:expect label="TOC content *should* be generated (nav content overwritten)"/>
98+
<x:context>
99+
<x:param name="autogenerate-toc" select="1"/>
100+
<x:param name="toc-placeholder-overwrite-contents" select="1"/>
101+
</x:context>
102+
<x:expect label="TOC content *should* be generated (nav content overwritten)"
103+
test="count(h:nav[.//h:li[contains(., 'This chapter head should be in TOC')]]) = 1 and
104+
not(exists(h:nav//h:h1[contains(., 'Manual TOC')]))"/>
74105
</x:scenario>
75106
</x:scenario>
107+
108+
<x:pending>
76109

110+
<!-- How many combinations of empty/nonempty nav, autogenerate-toc, and toc-placeholder-overwrite-contents do we need to do here? -->
77111
<x:scenario label="When there are multiple TOC nav elements">
78112
<x:context>
79113
<body>
80114
<nav data-type="toc"/>
81115
<nav data-type="toc"/>
82116
</body>
83117
</x:context>
84-
<x:expect label="Process them all per the same params"/>
118+
<x:expect label="Process them all the same way"/>
85119
</x:scenario>
86120

87121
<x:scenario label="When a TOC is generated with a scope specified">

0 commit comments

Comments
 (0)