http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88724

Revision: 88724
Author:   tparscal
Date:     2011-05-24 16:37:43 +0000 (Tue, 24 May 2011)
Log Message:
-----------
Added table and list tests.

Modified Paths:
--------------
    trunk/parsers/wikidom/README
    trunk/parsers/wikidom/tests/wikidom.test.js

Modified: trunk/parsers/wikidom/README
===================================================================
--- trunk/parsers/wikidom/README        2011-05-24 16:16:00 UTC (rev 88723)
+++ trunk/parsers/wikidom/README        2011-05-24 16:37:43 UTC (rev 88724)
@@ -41,4 +41,4 @@
 ; List
 : A series of item objects.
 ; Table
-: A series of rows, each a series of document objects.
\ No newline at end of file
+: A series of rows, each a series of columns, which contain document objects.
\ No newline at end of file

Modified: trunk/parsers/wikidom/tests/wikidom.test.js
===================================================================
--- trunk/parsers/wikidom/tests/wikidom.test.js 2011-05-24 16:16:00 UTC (rev 
88723)
+++ trunk/parsers/wikidom/tests/wikidom.test.js 2011-05-24 16:37:43 UTC (rev 
88724)
@@ -118,13 +118,8 @@
                                        'annotations': [
                                                {
                                                        'type': 'ilink',
-                                                       'range': {
-                                                               'offset': 15,
-                                                               'length': 4
-                                                       },
-                                                       'data': {
-                                                               'title': 
'Main_Page'
-                                                       }
+                                                       'range': { 'offset': 
15, 'length': 4 },
+                                                       'data': { 'title': 
'Main_Page' }
                                                }
                                        ]
                                }
@@ -166,20 +161,8 @@
                                        {
                                                'text': 'Line with bold and 
italic text',
                                                'annotations': [
-                                                       {
-                                                               'type': 'bold',
-                                                               'range': {
-                                                                       
'offset': 10,
-                                                                       
'length': 4
-                                                               }
-                                                       },
-                                                       {
-                                                               'type': 
'italic',
-                                                               'range': {
-                                                                       
'offset': 19,
-                                                                       
'length': 6
-                                                               }
-                                                       }
+                                                       { 'type': 'bold', 
'range': { 'offset': 10, 'length': 4 } },
+                                                       { 'type': 'italic', 
'range': { 'offset': 19, 'length': 6 } }
                                                ]
                                        }
                                ]
@@ -192,10 +175,109 @@
 
 // Lists
 test( 'Lists', function() {
-       assertSerializations( [] );
+       assertSerializations( [
+               {
+                       'subject': 'numbered list',
+                       'dom': { 'blocks': [ {
+                               'type': 'list',
+                               'style': 'number',
+                               'items': [
+                                       { 'line': { 'text': '1' } },
+                                       { 'line': { 'text': '2' } },
+                                       { 'line': { 'text': '3' } }
+                               ]
+                       } ] },
+                       'html': 
'<ol>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ol>',
+                       'wikitext': '# 1\n# 2\n# 3'
+               },
+               {
+                       'subject': 'bulleted list',
+                       'dom': { 'blocks': [ {
+                               'type': 'list',
+                               'style': 'bullet',
+                               'items': [
+                                       { 'line': { 'text': '1' } },
+                                       { 'line': { 'text': '2' } },
+                                       { 'line': { 'text': '3' } }
+                               ]
+                       } ] },
+                       'html': 
'<ul>\n<li>1</li>\n<li>2</li>\n<li>3</li>\n</ul>',
+                       'wikitext': '* 1\n* 2\n* 3'
+               },
+               {
+                       'subject': 'mixed-style nested lists',
+                       'dom': { 'blocks': [ {
+                               'type': 'list',
+                               'style': 'bullet',
+                               'items': [
+                                       {
+                                               'line': { 'text': '1' },
+                                               'lists': [
+                                                       {
+                                                               'style': 
'number',
+                                                               'items': [
+                                                                       { 
'line': { 'text': '1.1' } },
+                                                                       { 
'line': { 'text': '1.2' } },
+                                                                       { 
'line': { 'text': '1.3' } }
+                                                               ]
+                                                       }
+                                               ]
+                                       },
+                                       { 'line': { 'text': '2' } }
+                               ]
+                       } ] },
+                       'html': 
'<ul>\n<li>1\n<ol>\n<li>1.1</li>\n<li>1.2</li>\n<li>1.3</li>\n</ol>'
+                               + '\n</li>\n<li>2</li>\n</ul>',
+                       'wikitext': '* 1\n*# 1.1\n*# 1.2\n*# 1.3\n* 2'
+               }
+       ] );
 } );
 
 // Tables
 test( 'Tables', function() {
-       assertSerializations( [] );
+       assertSerializations( [
+               {
+                       'subject': 'table with headings and data',
+                       'dom': { 'blocks': [ {
+                               'type': 'table',
+                               'rows': [
+                                       [
+                                       {
+                                                       'type': 'heading',
+                                                       'document': { 'blocks': 
[{
+                                                               'type': 
'paragraph',
+                                                               'lines': [{ 
'text': 'A' }]
+                                                       }] }
+                                               },
+                                       {
+                                                       'type': 'heading',
+                                                       'document': { 'blocks': 
[{
+                                                               'type': 
'paragraph',
+                                                               'lines': [{ 
'text': 'B' }]
+                                                       }] }
+                                               }
+                               ],
+                                       [
+                                       {
+                                                       'type': 'data',
+                                                       'document': { 'blocks': 
[{
+                                                               'type': 
'paragraph',
+                                                               'lines': [{ 
'text': '1' }]
+                                                       }] }
+                                               },
+                                       {
+                                                       'type': 'data',
+                                                       'document': { 'blocks': 
[{
+                                                               'type': 
'paragraph',
+                                                               'lines': [{ 
'text': '2' }]
+                                                       }] }
+                                               }
+                               ]
+                               ]
+                       } ] },
+                       'html': 
'<table>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>\n<tr>\n'
+                               + '<td>1</td>\n<td>2</td>\n</tr>\n</table>',
+                       'wikitext': '{|\n!A\n!B\n|-\n|1\n|2\n|}'
+               }
+       ] );
 } );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to