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
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2013-07-03 01:30:10 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2021-08-25 08:31:34 +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
|
2021-04-30 09:33:22 +00:00
|
|
|
QUnit.test( 'getRenderedContents', ( assert ) => {
|
2021-04-29 14:42:18 +00:00
|
|
|
const 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',
|
2022-03-08 23:48:22 +00:00
|
|
|
originalDomElements: $.parseHTML( '<span rel="ve:Alien">e</span>' ),
|
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
|
|
|
],
|
2023-06-01 13:21:55 +00:00
|
|
|
html: ve.dm.example.singleLine`
|
|
|
|
a
|
|
|
|
<b>
|
|
|
|
b
|
|
|
|
<span class="ve-ce-leafNode ve-ce-mwEntityNode" contenteditable="false">c</span>
|
|
|
|
d
|
|
|
|
<span rel="ve:Alien" class="ve-ce-focusableNode ve-ce-leafNode" contenteditable="false">e</span>
|
|
|
|
</b>
|
|
|
|
`
|
2014-06-26 10:41:18 +00:00
|
|
|
} ];
|
2017-04-28 15:48:52 +00:00
|
|
|
|
2021-04-29 14:42:18 +00:00
|
|
|
for ( let i = 0; i < cases.length; i++ ) {
|
|
|
|
const 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
|
|
|
}
|
|
|
|
} );
|