mediawiki-extensions-Visual.../modules/ve/test/dm/ve.dm.Converter.test.js
Catrope 1234a702c9 (bug 42218) Add MWEntityNode
<span typeof="mw:Entity"> tags are now correctly represented in the
model, and rendered in CE. There are still issues with cursor movement
etc. in CE.

Because the prioritization mechanism for annotations vs nodes is broken
in the current "node API", I had to hack two special cases for mw:Entity
into the converter. I also had to change the converter to ignore the
children of inline nodes (this was a legitimate bug, but had never come
up before).

Change-Id: Ib9f70437c58b4ca06aa09f7272bf51d9c41b18f2
2012-11-20 16:19:55 -08:00

67 lines
1.6 KiB
JavaScript

/**
* VisualEditor data model Converter tests.
*
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
QUnit.module( 've.dm.Converter' );
/* Tests */
QUnit.test( 'getDataElementFromDomElement', 20, function ( assert ) {
var msg, conversion;
for ( msg in ve.dm.example.conversions ) {
conversion = ve.dm.example.conversions[msg];
assert.deepEqual(
ve.dm.converter.getDataElementFromDomElement( conversion.domElement ),
conversion.dataElement,
msg
);
}
} );
QUnit.test( 'getDomElementFromDataElement', 20, function ( assert ) {
var msg, conversion;
for ( msg in ve.dm.example.conversions ) {
conversion = ve.dm.example.conversions[msg];
assert.equalDomElement(
ve.dm.converter.getDomElementFromDataElement( conversion.dataElement ),
conversion.domElement,
msg
);
}
} );
QUnit.test( 'getDataFromDom', 36, function ( assert ) {
var msg,
cases = ve.dm.example.domToDataCases;
for ( msg in cases ) {
if ( cases[msg].html !== null ) {
ve.dm.example.preprocessAnnotations( cases[msg].data );
assert.deepEqual(
ve.dm.converter.getDataFromDom( $( '<div>' ).html( cases[msg].html )[0] ),
cases[msg].data,
msg
);
}
}
} );
QUnit.test( 'getDomFromData', 38, function ( assert ) {
var msg,
cases = ve.dm.example.domToDataCases;
for ( msg in cases ) {
ve.dm.example.preprocessAnnotations( cases[msg].data );
assert.equalDomElement(
ve.dm.converter.getDomFromData( cases[msg].data ),
$( '<div>' ).html( cases[msg].normalizedHtml || cases[msg].html )[0],
msg
);
}
} );