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-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>' +
|
|
|
|
'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++ ) {
|
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
|
|
|
}
|
|
|
|
} );
|