2013-07-03 01:30:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MediaWiki-specific ContentBranchNode tests.
|
|
|
|
*
|
2014-01-05 12:05:05 +00:00
|
|
|
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-03 01:30:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
QUnit.module( 've.ce.ContentBranchNode' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
|
|
|
// FIXME runner copypasted from core, use data provider
|
|
|
|
QUnit.test( 'getRenderedContents', function ( assert ) {
|
2014-03-16 23:53:03 +00:00
|
|
|
var i, len, doc, $wrapper,
|
2013-07-03 01:30:10 +00:00
|
|
|
cases = [
|
|
|
|
{
|
|
|
|
'msg': 'Annotation spanning text and inline nodes',
|
|
|
|
'data': [
|
|
|
|
{ 'type': 'paragraph' },
|
|
|
|
'a',
|
|
|
|
['b', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
{
|
|
|
|
'type': 'mwEntity',
|
|
|
|
'attributes': { 'character': 'c' },
|
|
|
|
'htmlAttributes': [ { 'keys': [ 'typeof' ], 'values': { 'typeof': 'mw:Entity' } } ],
|
|
|
|
'annotations': [ { 'type': 'textStyle/bold' } ]
|
|
|
|
},
|
|
|
|
{ 'type': '/mwEntity' },
|
|
|
|
['d', [ { 'type': 'textStyle/bold' } ]],
|
|
|
|
{
|
|
|
|
'type': 'alienInline',
|
|
|
|
'attributes': { 'domElements': $( '<tt>e</tt>' ).toArray() },
|
|
|
|
'annotations': [ { 'type': 'textStyle/bold' } ]
|
|
|
|
},
|
|
|
|
{ 'type': '/alienInline' },
|
|
|
|
{ 'type': '/paragraph' }
|
|
|
|
],
|
|
|
|
'html': 'a<b>b<span typeof="mw:Entity" class="ve-ce-leafNode ' +
|
|
|
|
've-ce-mwEntityNode" contenteditable="false">c</span>d<span ' +
|
2014-06-17 18:34:49 +00:00
|
|
|
'class="ve-ce-leafNode ve-ce-generatedContentNode ve-ce-noHighlight ' +
|
2013-09-05 20:25:35 +00:00
|
|
|
've-ce-alienNode ve-ce-alienInlineNode"><tt>e</tt></span></b>'
|
2013-07-03 01:30:10 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
QUnit.expect( cases.length );
|
|
|
|
for ( i = 0, len = cases.length; i < len; i++ ) {
|
|
|
|
doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( cases[i].data ) );
|
2014-03-16 23:53:03 +00:00
|
|
|
$wrapper = $( new ve.ce.ParagraphNode( doc.getDocumentNode().getChildren()[0] ).getRenderedContents() );
|
2013-07-03 01:30:10 +00:00
|
|
|
// HACK strip out all the class="ve-ce-TextStyleAnnotation ve-ce-TextStyleBoldAnnotation" crap
|
|
|
|
$wrapper.find( '.ve-ce-TextStyleAnnotation' ).removeAttr( 'class' );
|
|
|
|
assert.equalDomElement( $wrapper[0], $( '<div>' ).html( cases[i].html )[0], cases[i].msg );
|
|
|
|
}
|
|
|
|
} );
|