mediawiki-extensions-Visual.../modules/ve-mw/test/ce/ve.ce.ContentBranchNode.test.js
Ed Sanders b7343b5e07 Update VE core submodule to master (4c599b0)
Fix ContentBranchNode tests for getClientRects change.

New changes:
9bbd259 Create highlight elements on demand
a711c6d Indent demo HTML
b1b6562 Use cached surfaceView
d4b48b1 Replace <cite> with <span rel="ve:Alien">
ee5b697 Shields are dead, long live getClientRects
4c599b0 Remove repositionOnly argument from update

Change-Id: Ifa65c46d09864f214ece9349b990f7d8c07d416b
2014-06-17 16:18:29 -07:00

53 lines
1.9 KiB
JavaScript

/*!
* VisualEditor ContentEditable MediaWiki-specific ContentBranchNode tests.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
QUnit.module( 've.ce.ContentBranchNode' );
/* 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' },
'htmlAttributes': [ { 'keys': [ 'typeof' ], 'values': { 'typeof': 'mw:Entity' } } ],
'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 typeof="mw:Entity" class="ve-ce-leafNode ' +
've-ce-mwEntityNode" contenteditable="false">c</span>d<span ' +
'class="ve-ce-leafNode ve-ce-generatedContentNode ve-ce-noHighlight ' +
've-ce-alienNode ve-ce-alienInlineNode"><tt>e</tt></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 );
}
} );