2013-07-03 01:30:10 +00:00
|
|
|
/*!
|
2017-06-22 19:55:28 +00:00
|
|
|
* VisualEditor MediaWiki-specific ContentEditable ContentBranchNode tests.
|
2013-07-03 01:30:10 +00:00
|
|
|
*
|
2019-01-01 13:24:23 +00:00
|
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-03 01:30:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-05-17 09:37:34 +00:00
|
|
|
QUnit.module( 've.ce.ContentBranchNode (MW)', ve.test.utils.mwEnvironment );
|
2013-07-03 01:30:10 +00:00
|
|
|
|
|
|
|
/* 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,
|
2014-06-26 10:41:18 +00:00
|
|
|
cases = [ {
|
2014-08-22 20:50:48 +00:00
|
|
|
msg: 'Annotation spanning text and inline nodes',
|
|
|
|
data: [
|
|
|
|
{ type: 'paragraph' },
|
2013-07-03 01:30:10 +00:00
|
|
|
'a',
|
2015-07-22 22:13:09 +00:00
|
|
|
[ 'b', [ { type: 'textStyle/bold' } ] ],
|
2013-07-03 01:30:10 +00:00
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'mwEntity',
|
|
|
|
attributes: { character: 'c' },
|
|
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
2013-07-03 01:30:10 +00:00
|
|
|
},
|
2014-08-22 20:50:48 +00:00
|
|
|
{ type: '/mwEntity' },
|
2015-07-22 22:13:09 +00:00
|
|
|
[ 'd', [ { type: 'textStyle/bold' } ] ],
|
2013-07-03 01:30:10 +00:00
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
type: 'alienInline',
|
2015-03-25 15:00:40 +00:00
|
|
|
originalDomElements: $( '<span rel="ve:Alien">e</span>' ).toArray(),
|
2014-08-22 20:50:48 +00:00
|
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
2013-07-03 01:30:10 +00:00
|
|
|
},
|
2014-08-22 20:50:48 +00:00
|
|
|
{ type: '/alienInline' },
|
|
|
|
{ type: '/paragraph' }
|
2013-07-03 01:30:10 +00:00
|
|
|
],
|
2015-03-25 15:00:40 +00:00
|
|
|
html:
|
|
|
|
'a<b>b' +
|
|
|
|
'<span class="ve-ce-leafNode ve-ce-mwEntityNode" contenteditable="false">c</span>' +
|
2017-05-21 14:32:08 +00:00
|
|
|
'd<span rel="ve:Alien" class="ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">e</span>' +
|
2015-03-25 15:00:40 +00:00
|
|
|
'</b>'
|
2014-06-26 10:41:18 +00:00
|
|
|
} ];
|
2017-04-28 15:48:52 +00:00
|
|
|
|
2013-07-03 01:30:10 +00:00
|
|
|
for ( i = 0, len = cases.length; i < len; i++ ) {
|
2015-08-19 17:33:02 +00:00
|
|
|
doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( cases[ i ].data ) );
|
|
|
|
$wrapper = $( new ve.ce.ParagraphNode( doc.getDocumentNode().getChildren()[ 0 ] ).getRenderedContents() );
|
2014-08-22 21:09:16 +00:00
|
|
|
// HACK strip out all the class="ve-ce-textStyleAnnotation ve-ce-textStyleBoldAnnotation" crap
|
|
|
|
$wrapper.find( '.ve-ce-textStyleAnnotation' ).removeAttr( 'class' );
|
2015-08-19 17:33:02 +00:00
|
|
|
assert.equalDomElement( $wrapper[ 0 ], $( '<div>' ).html( cases[ i ].html )[ 0 ], cases[ i ].msg );
|
2013-07-03 01:30:10 +00:00
|
|
|
}
|
|
|
|
} );
|