2013-07-03 01:30:10 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor ContentEditable MediaWiki-specific ContentBranchNode tests.
|
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-03 01:30:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-02-13 19:46:28 +00:00
|
|
|
QUnit.module( 've.ce.ContentBranchNode (MW)' );
|
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',
|
2014-08-22 20:50:48 +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' },
|
|
|
|
['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>' +
|
|
|
|
'd<span rel="ve:Alien" class="ve-ce-focusableNode" contenteditable="false">e</span>' +
|
|
|
|
'</b>'
|
2014-06-26 10:41:18 +00:00
|
|
|
} ];
|
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() );
|
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' );
|
2013-07-03 01:30:10 +00:00
|
|
|
assert.equalDomElement( $wrapper[0], $( '<div>' ).html( cases[i].html )[0], cases[i].msg );
|
|
|
|
}
|
|
|
|
} );
|