2012-06-06 17:17:30 +00:00
|
|
|
module( 've.dm.Converter' );
|
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2012-06-07 00:47:27 +00:00
|
|
|
test( 'getDataElementFromDomElement', function() {
|
2012-06-06 17:17:30 +00:00
|
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
|
|
deepEqual(
|
2012-06-07 00:47:27 +00:00
|
|
|
ve.dm.converter.getDataElementFromDomElement( conversion.domElement ),
|
2012-06-06 17:17:30 +00:00
|
|
|
conversion.dataElement,
|
|
|
|
msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2012-06-07 00:47:27 +00:00
|
|
|
test( 'getDomElementFromDataElement', function() {
|
2012-06-06 17:17:30 +00:00
|
|
|
for ( var msg in ve.dm.example.conversions ) {
|
|
|
|
var conversion = ve.dm.example.conversions[msg];
|
|
|
|
deepEqual(
|
2012-06-07 00:47:27 +00:00
|
|
|
ve.example.getDomElementSummary(
|
|
|
|
ve.dm.converter.getDomElementFromDataElement( conversion.dataElement )
|
2012-06-06 17:17:30 +00:00
|
|
|
),
|
2012-06-07 00:47:27 +00:00
|
|
|
ve.example.getDomElementSummary( conversion.domElement ),
|
|
|
|
msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
test( 'getDataFromDom', function() {
|
2012-06-08 05:00:25 +00:00
|
|
|
var cases = ve.dm.example.domToDataCases;
|
2012-06-07 00:47:27 +00:00
|
|
|
for ( var msg in cases ) {
|
|
|
|
deepEqual(
|
|
|
|
ve.dm.converter.getDataFromDom( $( '<div></div>' ).html( cases[msg].html )[0] ),
|
|
|
|
cases[msg].data,
|
2012-06-06 17:17:30 +00:00
|
|
|
msg
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
2012-06-08 05:00:25 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|