mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-20 18:12:51 +00:00
e382d3af0a
Change-Id: Ica8773f54572bd90d4ee1ecde43254331fd2e313
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
/*!
|
|
* VisualEditor MediaWiki-specific ContentEditable ContentBranchNode tests.
|
|
*
|
|
* @copyright See AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.ContentBranchNode (MW)' );
|
|
|
|
/* Tests */
|
|
|
|
// FIXME runner copypasted from core, use data provider
|
|
QUnit.test( 'getRenderedContents', ( assert ) => {
|
|
const cases = [ {
|
|
msg: 'Annotation spanning text and inline nodes',
|
|
data: [
|
|
{ type: 'paragraph' },
|
|
'a',
|
|
[ 'b', [ { type: 'textStyle/bold' } ] ],
|
|
{
|
|
type: 'mwEntity',
|
|
attributes: { character: 'c' },
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
|
},
|
|
{ type: '/mwEntity' },
|
|
[ 'd', [ { type: 'textStyle/bold' } ] ],
|
|
{
|
|
type: 'alienInline',
|
|
originalDomElements: $.parseHTML( '<span rel="ve:Alien">e</span>' ),
|
|
annotations: [ { type: 'textStyle/bold' } ]
|
|
},
|
|
{ type: '/alienInline' },
|
|
{ type: '/paragraph' }
|
|
],
|
|
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>
|
|
`
|
|
} ];
|
|
|
|
cases.forEach( ( caseItem ) => {
|
|
const doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( caseItem.data ) ),
|
|
$wrapper = $( new ve.ce.ParagraphNode( doc.getDocumentNode().getChildren()[ 0 ] ).getRenderedContents() );
|
|
// 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( caseItem.html )[ 0 ], caseItem.msg );
|
|
} );
|
|
} );
|