|
14 | 14 |
|
15 | 15 | <x:param name="metadata.title" select="'Infinite Jest'"/>
|
16 | 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 | + |
17 | 30 | <x:scenario label="When generating full NCX TOC content">
|
18 | 31 | <x:call template="generate.ncx.toc.content">
|
19 | 32 | <!-- 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 -->
|
|
52 | 65 |
|
53 | 66 | <x:expect label="It should have a navMap with navPoint children for TOC elements" test="exists(/ncx:ncx/ncx:navMap[ncx:navPoint])"/>
|
54 | 67 |
|
55 |
| - <x:expect label="NavPoints should have playOrder attributes in consecutive order" |
| 68 | + <x:expect label="navPoints should have playOrder attributes in consecutive order" |
56 | 69 | test="not(exists(//ncx:navPoint[not(@playOrder)])) and
|
57 | 70 | count((//ncx:navPoint)[position() = @playOrder]) = count((//ncx:navPoint))"/>
|
58 | 71 | </x:scenario>
|
59 |
| - |
60 |
| - <x:pending> |
61 | 72 |
|
62 | 73 | <x:scenario label="When a book section/div is matched in ncx.toc.gen mode">
|
63 |
| - <x:context/> |
64 |
| - <x:expect label="return a NavPoint"/> |
| 74 | + <x:context mode="ncx.toc.gen"> |
| 75 | + <section data-type="chapter"> |
| 76 | + <h1>Test Chapter</h1> |
| 77 | + <p>It was the best of times!</p> |
| 78 | + </section> |
| 79 | + </x:context> |
| 80 | + <x:expect label="return a navPoint"> |
| 81 | + <ncx:navPoint id="...">...</ncx:navPoint> |
| 82 | + </x:expect> |
65 | 83 |
|
66 |
| - <x:scenario label="When source TOC elements are at a lower level than specified NCX Level"> |
67 |
| - <x:expect label="Don't generate a NavPoint"/> |
| 84 | + <x:scenario label="when source TOC elements are at a lower level than specified NCX Level"> |
| 85 | + <x:context mode="ncx.toc.gen" select="//h:section[@data-type='sect2'][1]"> |
| 86 | + <section data-type="chapter"> |
| 87 | + <h1>Test Chapter</h1> |
| 88 | + <p>It was the worst of times!</p> |
| 89 | + <section data-type="sect1"> |
| 90 | + <h1>Test Sect1</h1> |
| 91 | + <p>Two roads diverged in a wood</p> |
| 92 | + <section data-type="sect2"> |
| 93 | + <h2>Test Sect2</h2> |
| 94 | + <p>One fish, two fish, red fish, blue fish</p> |
| 95 | + </section> |
| 96 | + </section> |
| 97 | + </section> |
| 98 | + </x:context> |
| 99 | + <x:expect label="Don't generate a navPoint" test="not(exists(ncx:navPoint))"/> |
68 | 100 | </x:scenario>
|
69 | 101 | </x:scenario>
|
70 | 102 |
|
71 | 103 | <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">
|
72 |
| - <x:context/> |
73 |
| - <x:expect label="Don't generate a NavPoint"/> |
| 104 | + <x:context mode="ncx.toc.gen"> |
| 105 | + <div data-type="note"> |
| 106 | + <p>Notes should not get navPoints!!!</p> |
| 107 | + </div> |
| 108 | + </x:context> |
| 109 | + <x:expect label="Don't generate a navPoint" test="not(exists(ncx:navPoint))"/> |
74 | 110 | </x:scenario>
|
75 | 111 |
|
76 |
| - <x:scenario label="When a nav TOC is matched in ncx.toc.gen mode"> |
77 |
| - <x:context/> |
78 |
| - <x:expect label="Generate a NavPoint if $nav.in.ncx is specified"/> |
79 |
| - <x:expect label="*Do Not* generate a NavPoint if $nav.in.ncx *is not* specified"/> |
| 112 | + <x:scenario label="When a nav TOC is matched in ncx.toc.gen mode..."> |
| 113 | + <x:context mode="ncx.toc.gen"> |
| 114 | + <nav data-type="toc"/> |
| 115 | + </x:context> |
| 116 | + |
| 117 | + <x:scenario label="...with $nav.in.ncx enabled"> |
| 118 | + <x:context> |
| 119 | + <x:param name="nav.in.ncx" select="1"/> |
| 120 | + </x:context> |
| 121 | + <x:expect label="Generate a navPoint"> |
| 122 | + <ncx:navPoint id="...">...</ncx:navPoint> |
| 123 | + </x:expect> |
| 124 | + </x:scenario> |
| 125 | + |
| 126 | + <x:scenario label="...with $nav.in.ncx disabled"> |
| 127 | + <x:context> |
| 128 | + <x:param name="nav.in.ncx" select="0"/> |
| 129 | + </x:context> |
| 130 | + <x:expect label="*Do not* generate a navPoint" |
| 131 | + test="not(exists(ncx:navPoint))"/> |
| 132 | + </x:scenario> |
80 | 133 | </x:scenario>
|
81 | 134 |
|
82 | 135 | <x:scenario label="When generate.navpoint is called">
|
83 |
| - <x:call/> |
84 |
| - <x:expect label="A NavPoint element should be generated with proper id"/> |
85 |
| - <x:expect label="A NavLabel element should be generated with properly formatted heading text"/> |
86 |
| - <x:expect label="A NavLabel's text content should include labels if $ncx.toc.include.labels is specified"/> |
87 |
| - <x:expect label="A NavLabel's text content *should not* include labels if $ncx.toc.include.labels *is not* specified"/> |
88 |
| - <x:expect label="A NavLabel's text content *should not* contain any inline elements"/> |
89 |
| - <x:expect label="A NavPoint element should contain a src attribute with the proper href"/> |
| 136 | + <x:call template="generate.navpoint"> |
| 137 | + <x:param name="node"> |
| 138 | + <section data-type="appendix"> |
| 139 | + <h1>Tables of Crucial Data</h1> |
| 140 | + <p>Read me, please!</p> |
| 141 | + </section> |
| 142 | + </x:param> |
| 143 | + </x:call> |
| 144 | + <x:expect label="A navPoint element should be generated with proper id" |
| 145 | + test="count(ncx:navPoint[contains(@id, 'appendix')]) = 1"/> |
| 146 | + |
| 147 | + <x:expect label="A navLabel element should be generated with properly formatted heading text" |
| 148 | + test="count(ncx:navPoint/ncx:navLabel[contains(., 'Tables of Crucial Data')]) = 1"/> |
| 149 | + |
| 150 | + <x:scenario label="with $ncx.toc.include.label enabled"> |
| 151 | + <x:call> |
| 152 | + <x:param name="ncx.toc.include.labels" select="1"/> |
| 153 | + </x:call> |
| 154 | + <!-- Note: the following value is dependent on the global param set in this xspec document --> |
| 155 | + <!-- If test fails, double-check expected value is in sync with these params --> |
| 156 | + <x:expect label="A navLabel's text content should include labels" |
| 157 | + test="count(ncx:navPoint/ncx:navLabel[contains(., 'A. ')]) = 1"/> |
| 158 | + </x:scenario> |
| 159 | + |
| 160 | + <x:scenario label="with $ncx.toc.include.label disabled"> |
| 161 | + <x:call> |
| 162 | + <x:param name="ncx.toc.include.labels" select="0"/> |
| 163 | + </x:call> |
| 164 | + <x:expect label="A navLabel's text content *should not* include labels" |
| 165 | + test="count(ncx:navPoint/ncx:navLabel[not(contains(., '. '))]) = 1"/> |
| 166 | + </x:scenario> |
| 167 | + |
| 168 | + <x:scenario label="On a section with a title that contains inlines"> |
| 169 | + <x:call> |
| 170 | + <x:param name="node"> |
| 171 | + <section data-type="appendix"> |
| 172 | + <h1>Tables of <em>Really</em> Crucial Data</h1> |
| 173 | + <p>Read me, please!</p> |
| 174 | + </section> |
| 175 | + </x:param> |
| 176 | + </x:call> |
| 177 | + <x:expect label="A navLabel's text content *should not* contain any inline elements" |
| 178 | + test="not(exists(ncx:navPoint/ncx:navLabel/ncx:text/*))"/> |
| 179 | + </x:scenario> |
| 180 | + |
| 181 | + <!-- More robust testing here for src attribute value might be nice. --> |
| 182 | + <x:expect label="A navPoint element should contain a content element with a src attribute" |
| 183 | + test="exists(ncx:navPoint/ncx:content[@src])"/> |
| 184 | + |
90 | 185 | </x:scenario>
|
91 |
| - </x:pending> |
92 | 186 |
|
93 | 187 | </x:description>
|
0 commit comments