2017-06-22 19:55:28 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki-specific ContentEditable Document tests.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2017-06-22 19:55:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
QUnit.module( 've.ce.Document (MW)' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2021-04-30 09:33:22 +00:00
|
|
|
QUnit.test( 'Converter tests', ( assert ) => {
|
2021-04-29 14:42:18 +00:00
|
|
|
const cases = ve.dm.mwExample.domToDataCases;
|
2017-06-22 19:55:28 +00:00
|
|
|
|
2021-04-29 14:42:18 +00:00
|
|
|
for ( const msg in cases ) {
|
2017-06-22 19:55:28 +00:00
|
|
|
if ( cases[ msg ].ceHtml ) {
|
2023-01-21 17:00:26 +00:00
|
|
|
const caseItem = ve.copy( cases[ msg ] );
|
|
|
|
caseItem.base = caseItem.base || ve.dm.mwExample.baseUri;
|
|
|
|
const model = ve.test.utils.getModelFromTestCase( caseItem );
|
|
|
|
const view = new ve.ce.Document( model );
|
|
|
|
const $documentElement = view.getDocumentNode().$element;
|
2017-06-22 19:55:28 +00:00
|
|
|
// 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 ],
|
2023-01-21 16:30:47 +00:00
|
|
|
$( '<div>' ).html( caseItem.ceHtml )[ 0 ],
|
2017-06-22 19:55:28 +00:00
|
|
|
msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} );
|