Index: trunk/parsers/wikidom/tests/serializers/test.js |
— | — | @@ -4,21 +4,35 @@ |
5 | 5 | htmlSerializer = new es.Document.HtmlSerializer( context ), |
6 | 6 | wikitextSerializer = new es.Document.WikitextSerializer( context ); |
7 | 7 | |
8 | | -function assertSerializations( tests ) { |
| 8 | +function assertSerializations( tests, domToDom ) { |
9 | 9 | for ( var i = 0; i < tests.length; i++ ) { |
10 | | - equals( |
11 | | - htmlSerializer.serializeDocument( tests[i].dom ), |
12 | | - tests[i].html, |
13 | | - 'Serialize ' + tests[i].subject + ' to HTML' |
14 | | - ); |
| 10 | + if ( typeof tests[i].html !== 'undefined' ) { |
| 11 | + equals( |
| 12 | + htmlSerializer.serializeDocument( tests[i].dom ), |
| 13 | + tests[i].html, |
| 14 | + 'Serialize ' + tests[i].subject + ' to HTML' |
| 15 | + ); |
| 16 | + } |
15 | 17 | } |
16 | 18 | for ( var i = 0; i < tests.length; i++ ) { |
17 | | - equals( |
18 | | - wikitextSerializer.serializeDocument( tests[i].dom ), |
19 | | - tests[i].wikitext, |
20 | | - 'Serialize ' + tests[i].subject + ' to Wikitext' |
21 | | - ); |
| 19 | + if ( typeof tests[i].wikitext !== 'undefined' ) { |
| 20 | + equals( |
| 21 | + wikitextSerializer.serializeDocument( tests[i].dom ), |
| 22 | + tests[i].wikitext, |
| 23 | + 'Serialize ' + tests[i].subject + ' to Wikitext' |
| 24 | + ); |
| 25 | + } |
22 | 26 | } |
| 27 | + if ( typeof domToDom !== 'undefined' && domToDom === true ) { |
| 28 | + var doc; |
| 29 | + for ( var i = 0; i < tests.length; i++ ) { |
| 30 | + deepEqual( |
| 31 | + doc = es.Document.newFromWikiDomDocument( tests[i].dom ).getWikiDomDocument(), |
| 32 | + tests[i].dom, |
| 33 | + 'Serialize ' + tests[i].subject + ' to Wikidom' |
| 34 | + ); |
| 35 | + } |
| 36 | + } |
23 | 37 | } |
24 | 38 | |
25 | 39 | test( 'Comments', function() { |
— | — | @@ -172,7 +186,7 @@ |
173 | 187 | 'html': '<p>Line with <strong>bold</strong> and <em>italic</em> text</p>', |
174 | 188 | 'wikitext': 'Line with \'\'\'bold\'\'\' and \'\'italic\'\' text' |
175 | 189 | } |
176 | | - ] ); |
| 190 | + ], true ); |
177 | 191 | } ); |
178 | 192 | |
179 | 193 | // Lists |
— | — | @@ -207,7 +221,7 @@ |
208 | 222 | 'wikitext': '* 1\n* 2\n* 3' |
209 | 223 | }, |
210 | 224 | { |
211 | | - 'subject': 'mixed-style nested lists', |
| 225 | + 'subject': 'mixed-style nested lists (1)', |
212 | 226 | 'dom': { 'blocks': [ { |
213 | 227 | 'type': 'list', |
214 | 228 | 'style': 'bullet', |
— | — | @@ -231,8 +245,47 @@ |
232 | 246 | 'html': '<ul>\n<li>1\n<ol>\n<li>1.1</li>\n<li>1.2</li>\n<li>1.3</li>\n</ol>' |
233 | 247 | + '\n</li>\n<li>2</li>\n</ul>', |
234 | 248 | 'wikitext': '* 1\n*# 1.1\n*# 1.2\n*# 1.3\n* 2' |
| 249 | + }, |
| 250 | + { |
| 251 | + 'subject': 'mixed-style nested lists (2)', |
| 252 | + 'dom': { 'blocks': [ { |
| 253 | + 'type': 'list', |
| 254 | + 'style': 'bullet', |
| 255 | + 'items': [ |
| 256 | + { |
| 257 | + 'line': { 'text': '1' }, |
| 258 | + 'lists': [ |
| 259 | + { |
| 260 | + 'style': 'number', |
| 261 | + 'items': [ |
| 262 | + { 'line': { 'text': '1.1' } }, |
| 263 | + { 'line': { 'text': '1.2' } }, |
| 264 | + { 'line': { 'text': '1.3' } } |
| 265 | + ] |
| 266 | + }, |
| 267 | + { |
| 268 | + 'style': 'bullet', |
| 269 | + 'items': [ |
| 270 | + { 'line': { 'text': '1.4' } }, |
| 271 | + { 'line': { 'text': '1.5' } }, |
| 272 | + { 'line': { 'text': '1.6' } } |
| 273 | + ] |
| 274 | + }, |
| 275 | + { |
| 276 | + 'style': 'number', |
| 277 | + 'items': [ |
| 278 | + { 'line': { 'text': '1.7' } }, |
| 279 | + { 'line': { 'text': '1.8' } }, |
| 280 | + { 'line': { 'text': '1.9' } } |
| 281 | + ] |
| 282 | + } |
| 283 | + ] |
| 284 | + }, |
| 285 | + { 'line': { 'text': '2' } } |
| 286 | + ] |
| 287 | + } ] } |
235 | 288 | } |
236 | | - ] ); |
| 289 | + ], true ); |
237 | 290 | } ); |
238 | 291 | |
239 | 292 | // Tables |