/*! * 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.each( 'getRenderedContents', { '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( 'e' ), annotations: [ { type: 'textStyle/bold' } ] }, { type: '/alienInline' }, { type: '/paragraph' } ], html: ve.dm.example.singleLine` a b c d e ` } }, ( assert, { data, html } ) => { const doc = new ve.dm.Document( ve.dm.example.preprocessAnnotations( data ) ); const $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 ], $( '
' ).html( html )[ 0 ] ); } );