mediawiki-extensions-Visual.../modules/ve-mw/tests/ce/ve.ce.Document.test.js
Ed Sanders c4f93b1411 Ensure MWInlineImages get the ve-ce-leafNode class
Without this class, offset calculations fail and model/view
sync can be lost.

Bug: T167009
Change-Id: Ie7b6551ac5a532949c14122b9ee7584a794af0f2
2017-06-26 12:43:23 +00:00

32 lines
985 B
JavaScript

/*!
* VisualEditor MediaWiki-specific ContentEditable Document tests.
*
* @copyright 2011-2017 VisualEditor Team and others; see http://ve.mit-license.org
*/
QUnit.module( 've.ce.Document (MW)' );
/* Tests */
QUnit.test( 'Converter tests', function ( assert ) {
var msg, model, view, caseItem, $documentElement,
cases = ve.dm.mwExample.domToDataCases;
for ( msg in cases ) {
if ( cases[ msg ].ceHtml ) {
caseItem = ve.copy( cases[ msg ] );
model = ve.test.utils.getModelFromTestCase( caseItem );
view = new ve.ce.Document( model );
$documentElement = view.getDocumentNode().$element;
// Simplify slugs
$documentElement.find( '.ve-ce-branchNode-slug' ).contents().remove();
assert.equalDomElement(
// Wrap both in plain DIVs as we are only comparing the child nodes
$( '<div>' ).append( $documentElement.contents() )[ 0 ],
$( '<div>' ).append( ve.createDocumentFromHtml( caseItem.ceHtml ).body.childNodes )[ 0 ],
msg
);
}
}
} );