mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 17:36:35 +00:00
8d33a3de0d
* Made method descriptions imperative: "Do this" rather than "Does this" * Changed use of "this object" to "the object" in method documentation * Added missing documentation * Fixed incorrect documentation * Fixed incorrect debug method names (as in those VeDmClassName tags we add to functions so they make sense when dumped into in the console) * Normalized use of package names throughout * Normalized class descriptions * Removed incorrect @abstract tags * Added missing @method tags * Lots of other minor cleanup Change-Id: I4ea66a2dd107613e2ea3a5f56ff54d675d72957e
153 lines
4.3 KiB
JavaScript
153 lines
4.3 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable TextNode tests.
|
|
*
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.TextNode' );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'getAnnotatedHtml', function ( assert ) {
|
|
var i, len, cases;
|
|
|
|
cases = [
|
|
{
|
|
'data': [
|
|
{ 'type': 'paragraph' },
|
|
'a',
|
|
'b',
|
|
'c',
|
|
{ 'type': '/paragraph' }
|
|
],
|
|
'html': [ 'a', 'b', 'c' ]
|
|
},
|
|
{
|
|
'data': [
|
|
{ 'type': 'paragraph' },
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
|
['c', [ { 'type': 'textStyle/bold' } ]],
|
|
{ 'type': '/paragraph' }
|
|
],
|
|
'html': [
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
|
['c', [ { 'type': 'textStyle/bold' } ]]
|
|
]
|
|
},
|
|
{
|
|
'data': [
|
|
{ 'type': 'paragraph' },
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
'b',
|
|
['c', [ { 'type': 'textStyle/italic' } ]],
|
|
{ 'type': '/paragraph' }
|
|
],
|
|
'html': [
|
|
['a', [ { 'type': 'textStyle/bold' } ]],
|
|
'b',
|
|
['c', [ { 'type': 'textStyle/italic' } ]]
|
|
]
|
|
},
|
|
{
|
|
// [ ]
|
|
'data': [{ 'type': 'paragraph' },{ 'type': '/paragraph' }],
|
|
'html': []
|
|
},
|
|
{
|
|
// [ ]
|
|
'data': [{ 'type': 'paragraph' },' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', ' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][A][ ][ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', 'A', ' ', ' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', 'A', ' ', ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][A][ ][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', 'A', ' ', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', 'A', ' ', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][A][ ][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', 'A', ' ', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', 'A', ' ', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][ ][A][ ]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', ' ', 'A', ' ',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', ' ', 'A', ' ' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][ ][ ][A]
|
|
'data': [{ 'type': 'paragraph' },' ', ' ', ' ', ' ', ' ', 'A',{ 'type': '/paragraph' }],
|
|
'html': [ ' ', ' ', ' ', ' ', ' ', 'A' ]
|
|
},
|
|
{
|
|
'data': [{ 'type': 'paragraph' }, '\n', 'A', '\n', 'B', '\n', { 'type': '/paragraph' }],
|
|
'html': [ '↵', 'A', '↵', 'B', '↵' ]
|
|
},
|
|
{
|
|
'data': [{ 'type': 'paragraph' }, '\t', 'A', '\t', 'B', '\t', { 'type': '/paragraph' }],
|
|
'html': [ '➞', 'A', '➞', 'B', '➞' ]
|
|
},
|
|
{
|
|
'data': [{ 'type': 'preformatted' }, '\n', 'A', '\n', 'B', '\n', { 'type': '/preformatted' }],
|
|
'html': [ '\n', 'A', '\n', 'B', '\n' ]
|
|
},
|
|
{
|
|
'data': [{ 'type': 'preformatted' }, '\t', 'A', '\t', 'B', '\t', { 'type': '/preformatted' }],
|
|
'html': [ '\t', 'A', '\t', 'B', '\t' ]
|
|
},
|
|
{
|
|
// [ ][ ][ ][A][ ][ ]
|
|
'data': [{ 'type': 'preformatted' },' ', ' ', ' ', 'A', ' ', ' ',{ 'type': '/preformatted' }],
|
|
'html': [ ' ', ' ', ' ', 'A', ' ', ' ' ]
|
|
},
|
|
{
|
|
'data': [{ 'type': 'paragraph' }, '&', '<', '>', '\'', '"', { 'type': '/paragraph' }],
|
|
'html': [ '&', '<', '>', ''', '"' ]
|
|
}
|
|
];
|
|
QUnit.expect( cases.length );
|
|
for ( i = 0, len = cases.length; i < len; i++ ) {
|
|
ve.dm.example.preprocessAnnotations( cases[i].data );
|
|
ve.dm.example.preprocessAnnotations( cases[i].html );
|
|
assert.deepEqual(
|
|
( new ve.ce.TextNode(
|
|
( new ve.dm.Document( cases[i].data ) )
|
|
.documentNode.getChildren()[0].getChildren()[0] )
|
|
).getAnnotatedHtml(),
|
|
cases[i].html
|
|
);
|
|
}
|
|
} );
|