mediawiki-extensions-Visual.../modules/ve-mw/tests/ce/ve.ce.ContentBranchNode.test.js
James D. Forrester 497e7eb4a1 Update VE core submodule to master (cb06317)
New changes:
5197b2d Rangestate optimization
80a07cf Unmix GeneratedContentNode from AlienNodes
f510e9c Make (Node/Annotation/MetaItem)Factory inherit from ModelFactory
b625ff0 Localisation updates from https://translatewiki.net.
5c4653c ve.qunit: Use 'jscs:disable' comment rather than hacks
90e9480 Remove registration of abstract AlienNode classes
d325674 i18n/en.json: Convert from spaces to tabs, like all other files
f40fc15 Add 'classes' config option to focusable nodes to simplify AlienNode
f7c8999 Document config options as @cfg
ad3aa0b ve.ce.Surface.test: Groundwork for testing non-linear selections
cd1a992 Localisation updates from https://translatewiki.net.
c92471e Move drop marker to highlights layer and position absolutely

Change-Id: I437663d93a346a06c6a5137cce5149c7a6fcbb7f
2015-03-25 18:20:35 +00:00

51 lines
1.7 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',
originalDomElements: $( '<span rel="ve:Alien">e</span>' ).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<span rel="ve:Alien" class="ve-ce-focusableNode" contenteditable="false">e</span>' +
'</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 );
}
} );