|
12 | 12 |
|
13 | 13 | <!-- Global params for testing -->
|
14 | 14 |
|
15 |
| - <x:pending> |
16 |
| - <x:scenario label="When generating full NCX TOC content"> |
17 |
| - <x:call template="generate.ncx.toc.content"/> |
18 |
| - <x:expect label="It should have the standard ncx root element"/> |
19 |
| - <x:expect label="It should have a meta element for the cover HTML if generate.cover.html is specified"/> |
20 |
| - <x:expect label="It *should not* have a meta element for the cover HTML if generate.cover.html *is not* specified"/> |
21 |
| - <x:expect label="It should have the book title in a docTitle element"/> |
22 |
| - <x:expect label="It should have a navMap with navPoint children for TOC elements"/> |
23 |
| - <x:expect label="NavPoints should have playOrder attributes in consecutive order"/> |
| 15 | + <x:param name="metadata.title" select="'Infinite Jest'"/> |
| 16 | + |
| 17 | + <x:param name="label.and.title.separator" select="'. '"/> |
| 18 | + |
| 19 | + <x:param name="label.numeration.by.data-type"> |
| 20 | +appendix:A |
| 21 | +chapter:1 |
| 22 | +part:I |
| 23 | +sect1:none |
| 24 | +sect2:none |
| 25 | +sect3:none |
| 26 | +sect4:none |
| 27 | +sect5:none |
| 28 | + </x:param> |
| 29 | + |
| 30 | + <x:param name="ncx.toc.section.depth" select="2"/> |
| 31 | + |
| 32 | + <x:scenario label="When generating full NCX TOC content"> |
| 33 | + <x:call template="generate.ncx.toc.content"> |
| 34 | + <!-- Test XSL is output to a subdir of the .xspec dir, which also contains skeleton, so relative path contains .. to go up a directory level --> |
| 35 | + <x:param name="toc.node" select="document('../skeleton.html')/*"/> |
| 36 | + </x:call> |
| 37 | + |
| 38 | + <x:expect label="It should have the standard ncx root element"> |
| 39 | + <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">...</ncx> |
| 40 | + </x:expect> |
| 41 | + |
| 42 | + <x:scenario label="With generate.cover.html disabled"> |
| 43 | + <x:call> |
| 44 | + <x:param name="generate.cover.html"/> |
| 45 | + </x:call> |
| 46 | + <x:expect label="It *should not* have a meta element for the cover HTML" test="not(exists(/ncx:ncx/ncx:head/ncx:meta[@name='cover']))"/> |
| 47 | + </x:scenario> |
| 48 | + |
| 49 | + <x:scenario label="With generate.cover.html enabled"> |
| 50 | + <x:call> |
| 51 | + <x:param name="generate.cover.html">1</x:param> |
| 52 | + </x:call> |
| 53 | + <x:expect label="It should have a meta element for the cover HTML" test="count(/ncx:ncx/ncx:head/ncx:meta[@name='cover']) = 1"/> |
24 | 54 | </x:scenario>
|
25 | 55 |
|
| 56 | + <x:pending> |
| 57 | + <x:scenario label="With ncx.include.root.chunk enabled"> |
| 58 | + <x:expect label="navPoint for root chunk should be generated"/> |
| 59 | + </x:scenario> |
| 60 | + |
| 61 | + <x:scenario label="With ncx.include.root.chunk disabled"> |
| 62 | + <x:expect label="navPoint for root chunk *should not* be generated"/> |
| 63 | + </x:scenario> |
| 64 | + </x:pending> |
| 65 | + |
| 66 | + <x:expect label="It should have the book title in a docTitle element" test="exists(/ncx:ncx/ncx:docTitle[. = 'Infinite Jest'])"/> |
| 67 | + |
| 68 | + <x:expect label="It should have a navMap with navPoint children for TOC elements" test="exists(/ncx:ncx/ncx:navMap[ncx:navPoint])"/> |
| 69 | + |
| 70 | + <x:expect label="navPoints should have playOrder attributes in consecutive order" |
| 71 | + test="not(exists(//ncx:navPoint[not(@playOrder)])) and |
| 72 | + count((//ncx:navPoint)[position() = @playOrder]) = count((//ncx:navPoint))"/> |
| 73 | + </x:scenario> |
| 74 | + |
26 | 75 | <x:scenario label="When a book section/div is matched in ncx.toc.gen mode">
|
27 |
| - <x:context/> |
28 |
| - <x:expect label="return a NavPoint"/> |
| 76 | + <x:context mode="ncx.toc.gen"> |
| 77 | + <section data-type="chapter"> |
| 78 | + <h1>Test Chapter</h1> |
| 79 | + <p>It was the best of times!</p> |
| 80 | + </section> |
| 81 | + </x:context> |
| 82 | + <x:expect label="return a navPoint"> |
| 83 | + <ncx:navPoint id="...">...</ncx:navPoint> |
| 84 | + </x:expect> |
29 | 85 |
|
30 |
| - <x:scenario label="When source TOC elements are at a lower level than specified NCX Level"> |
31 |
| - <x:expect label="Don't generate a NavPoint"/> |
| 86 | + <!-- Note: the following test is dependent on the global param set in this xspec document --> |
| 87 | + <!-- If test fails, double-check expected value is in sync with these params --> |
| 88 | + <x:scenario label="when source TOC elements are at a lower level than specified NCX Level"> |
| 89 | + <x:context mode="ncx.toc.gen" select="//h:section[@data-type='sect3'][1]"> |
| 90 | + <section data-type="chapter"> |
| 91 | + <h1>Test Chapter</h1> |
| 92 | + <p>It was the worst of times!</p> |
| 93 | + <section data-type="sect1"> |
| 94 | + <h1>Test Sect1</h1> |
| 95 | + <p>Two roads diverged in a wood</p> |
| 96 | + <section data-type="sect2"> |
| 97 | + <h2>Test Sect2</h2> |
| 98 | + <p>One fish, two fish, red fish, blue fish</p> |
| 99 | + <section data-type="sect3"> |
| 100 | + <h3>Test SEct3</h3> |
| 101 | + <p>It was a dark and stormy night</p> |
| 102 | + </section> |
| 103 | + </section> |
| 104 | + </section> |
| 105 | + </section> |
| 106 | + </x:context> |
| 107 | + <x:expect label="Don't generate a navPoint" test="not(exists(ncx:navPoint))"/> |
32 | 108 | </x:scenario>
|
33 | 109 | </x:scenario>
|
34 | 110 |
|
35 | 111 | <x:scenario label="When a non-book section/div is matched in ncx.toc.gen mode that does not have a book section/div child">
|
36 |
| - <x:context/> |
37 |
| - <x:expect label="Don't generate a NavPoint"/> |
| 112 | + <x:context mode="ncx.toc.gen"> |
| 113 | + <div data-type="note"> |
| 114 | + <p>Notes should not get navPoints!!!</p> |
| 115 | + </div> |
| 116 | + </x:context> |
| 117 | + <x:expect label="Don't generate a navPoint" test="not(exists(ncx:navPoint))"/> |
38 | 118 | </x:scenario>
|
39 | 119 |
|
40 |
| - <x:scenario label="When a nav TOC is matched in ncx.toc.gen mode"> |
41 |
| - <x:context/> |
42 |
| - <x:expect label="Generate a NavPoint if $nav.in.ncx is specified"/> |
43 |
| - <x:expect label="*Do Not* generate a NavPoint if $nav.in.ncx *is not* specified"/> |
| 120 | + <x:scenario label="When a nav TOC is matched in ncx.toc.gen mode..."> |
| 121 | + <x:context mode="ncx.toc.gen"> |
| 122 | + <nav data-type="toc"/> |
| 123 | + </x:context> |
| 124 | + |
| 125 | + <x:scenario label="...with $nav.in.ncx enabled"> |
| 126 | + <x:context> |
| 127 | + <x:param name="nav.in.ncx" select="1"/> |
| 128 | + </x:context> |
| 129 | + <x:expect label="Generate a navPoint"> |
| 130 | + <ncx:navPoint id="...">...</ncx:navPoint> |
| 131 | + </x:expect> |
| 132 | + </x:scenario> |
| 133 | + |
| 134 | + <x:scenario label="...with $nav.in.ncx disabled"> |
| 135 | + <x:context> |
| 136 | + <x:param name="nav.in.ncx" select="0"/> |
| 137 | + </x:context> |
| 138 | + <x:expect label="*Do not* generate a navPoint" |
| 139 | + test="not(exists(ncx:navPoint))"/> |
| 140 | + </x:scenario> |
44 | 141 | </x:scenario>
|
45 | 142 |
|
46 | 143 | <x:scenario label="When generate.navpoint is called">
|
47 |
| - <x:call/> |
48 |
| - <x:expect label="A NavPoint element should be generated with proper id"/> |
49 |
| - <x:expect label="A NavLabel element should be generated with properly formatted heading text"/> |
50 |
| - <x:expect label="A NavLabel's text content should include labels if $ncx.toc.include.labels is specified"/> |
51 |
| - <x:expect label="A NavLabel's text content *should not* include labels if $ncx.toc.include.labels *is not* specified"/> |
52 |
| - <x:expect label="A NavLabel's text content *should not* contain any inline elements"/> |
53 |
| - <x:expect label="A NavPoint element should contain a src attribute with the proper href"/> |
| 144 | + <x:call template="generate.navpoint"> |
| 145 | + <x:param name="node"> |
| 146 | + <section data-type="appendix"> |
| 147 | + <h1>Tables of Crucial Data</h1> |
| 148 | + <p>Read me, please!</p> |
| 149 | + </section> |
| 150 | + </x:param> |
| 151 | + </x:call> |
| 152 | + <x:expect label="A navPoint element should be generated with proper id" |
| 153 | + test="count(ncx:navPoint[contains(@id, 'appendix')]) = 1"/> |
| 154 | + |
| 155 | + <x:expect label="A navLabel element should be generated with properly formatted heading text" |
| 156 | + test="count(ncx:navPoint/ncx:navLabel[contains(., 'Tables of Crucial Data')]) = 1"/> |
| 157 | + |
| 158 | + <x:scenario label="with $ncx.toc.include.label enabled"> |
| 159 | + <x:call> |
| 160 | + <x:param name="ncx.toc.include.labels" select="1"/> |
| 161 | + </x:call> |
| 162 | + <!-- Note: the following value is dependent on the global params set in this xspec document --> |
| 163 | + <!-- If test fails, double-check expected value is in sync with these params --> |
| 164 | + <x:expect label="A navLabel's text content should include labels" |
| 165 | + test="count(ncx:navPoint/ncx:navLabel[contains(., 'A. ')]) = 1"/> |
| 166 | + </x:scenario> |
| 167 | + |
| 168 | + <x:scenario label="with $ncx.toc.include.label disabled"> |
| 169 | + <x:call> |
| 170 | + <x:param name="ncx.toc.include.labels" select="0"/> |
| 171 | + </x:call> |
| 172 | + <x:expect label="A navLabel's text content *should not* include labels" |
| 173 | + test="count(ncx:navPoint/ncx:navLabel[not(contains(., '. '))]) = 1"/> |
| 174 | + </x:scenario> |
| 175 | + |
| 176 | + <x:scenario label="On a section with a title that contains inlines"> |
| 177 | + <x:call> |
| 178 | + <x:param name="node"> |
| 179 | + <section data-type="appendix"> |
| 180 | + <h1>Tables of <em>Really</em> Crucial Data</h1> |
| 181 | + <p>Read me, please!</p> |
| 182 | + </section> |
| 183 | + </x:param> |
| 184 | + </x:call> |
| 185 | + <x:expect label="A navLabel's text content *should not* contain any inline elements" |
| 186 | + test="not(exists(ncx:navPoint/ncx:navLabel/ncx:text/*))"/> |
| 187 | + </x:scenario> |
| 188 | + |
| 189 | + <!-- More robust testing here for src attribute value might be nice. --> |
| 190 | + <x:expect label="A navPoint element should contain a content element with a src attribute" |
| 191 | + test="exists(ncx:navPoint/ncx:content[@src])"/> |
| 192 | + |
54 | 193 | </x:scenario>
|
55 |
| - </x:pending> |
56 | 194 |
|
57 | 195 | </x:description>
|
0 commit comments