mediawiki-extensions-Visual.../tests/ve/dm/ve.dm.Converter.test.js
Catrope 748b34cc49 ve2 -> ve in the tests directory too
Change-Id: I30b56b1c43202d8cb6af397d2813b19b1a71d30e
2012-06-19 18:36:34 -07:00

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
);
}
});