mediawiki-extensions-Visual.../modules/ve-mw/tests/ce/ve.ce.ContentBranchNode.test.js
Roan Kattouw 3611664663 Update VE core submodule to master (7d2a68e)
New changes:
0ceafd5 Fix V8 deopt for ve.ce.BranchNode#onSplice
01d2d4b [BREAKING CHANGE] Store originalDomElements instead of htmlAttributes
96005a7 Localisation updates from https://translatewiki.net.
42e672e ve.ui.Toolbar: Don't call #updateToolState from #initialize
373562d Localisation updates from https://translatewiki.net.

Local changes:
Update for htmlAttributes going away

Change-Id: I576a1e5d5883b03d1fff6666926f80a5682a280f
2015-02-18 15:35:46 -08:00

48 lines
1.6 KiB
JavaScript

/*!
* VisualEditor ContentEditable MediaWiki-specific ContentBranchNode tests.
*
* @copyright 2011-2015 VisualEditor Team and others; 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', function ( assert ) {
var i, len, doc, $wrapper,
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',
attributes: { domElements: $( '<tt>e</tt>' ).toArray() },
annotations: [ { type: 'textStyle/bold' } ]
},
{ type: '/alienInline' },
{ type: '/paragraph' }
],
html: 'a<b>b<span class="ve-ce-leafNode ' +
've-ce-mwEntityNode" contenteditable="false">c</span>d<tt>e</tt></b>'
} ];
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 ) );
$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( cases[i].html )[0], cases[i].msg );
}
} );