mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
ef0e4b4973
Also updated tests to use the new assert as an argument style Change-Id: I3c82b4b068134bba755ae4a5c26f5bb98d400c43
55 lines
1.3 KiB
JavaScript
55 lines
1.3 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
|
|
*/
|
|
|
|
module( 've.dm.Converter' );
|
|
|
|
/* Tests */
|
|
|
|
test( 'getDataElementFromDomElement', function( assert ) {
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
assert.deepEqual(
|
|
ve.dm.converter.getDataElementFromDomElement( conversion.domElement ),
|
|
conversion.dataElement,
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDomElementFromDataElement', function( assert ) {
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
assert.equalDomElement(
|
|
ve.dm.converter.getDomElementFromDataElement( conversion.dataElement ),
|
|
conversion.domElement,
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDataFromDom', function( assert ) {
|
|
var cases = ve.dm.example.domToDataCases;
|
|
for ( var msg in cases ) {
|
|
assert.deepEqual(
|
|
ve.dm.converter.getDataFromDom( $( '<div></div>' ).html( cases[msg].html )[0] ),
|
|
cases[msg].data,
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDomFromData', function( assert ) {
|
|
var cases = ve.dm.example.domToDataCases;
|
|
for ( var msg in cases ) {
|
|
assert.equalDomElement(
|
|
ve.dm.converter.getDomFromData( cases[msg].data ),
|
|
$( '<div></div>' ).html( cases[msg].html )[0],
|
|
msg
|
|
);
|
|
}
|
|
} );
|