mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
911ee3229a
Move the test cases for getDataFromDom out into ve.dm.example and use them to test getDomFromData as well Change-Id: Ib33854a7a1e8cb6a8ebf2c5b88cd5c17e25644b2
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
module( 've.dm.Converter' );
|
|
|
|
/* Tests */
|
|
|
|
test( 'getDataElementFromDomElement', function() {
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
deepEqual(
|
|
ve.dm.converter.getDataElementFromDomElement( conversion.domElement ),
|
|
conversion.dataElement,
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDomElementFromDataElement', function() {
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
deepEqual(
|
|
ve.example.getDomElementSummary(
|
|
ve.dm.converter.getDomElementFromDataElement( conversion.dataElement )
|
|
),
|
|
ve.example.getDomElementSummary( conversion.domElement ),
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDataFromDom', function() {
|
|
var cases = ve.dm.example.domToDataCases;
|
|
for ( var msg in cases ) {
|
|
deepEqual(
|
|
ve.dm.converter.getDataFromDom( $( '<div></div>' ).html( cases[msg].html )[0] ),
|
|
cases[msg].data,
|
|
msg
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'getDomFromData', function() {
|
|
var cases = ve.dm.example.domToDataCases;
|
|
for ( var msg in cases ) {
|
|
deepEqual(
|
|
ve.example.getDomElementSummary( ve.dm.converter.getDomFromData( cases[msg].data ) ),
|
|
ve.example.getDomElementSummary( $( '<div></div>' ).html( cases[msg].html )[0] ),
|
|
msg
|
|
);
|
|
}
|
|
});
|