mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-03 02:16:51 +00:00
189e3eddbe
Change-Id: I9b0fa2de44381b363fb6e612884f9911996e941b
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
module( 've.dm.HTMLConverter' );
|
|
|
|
// Tests
|
|
|
|
test( 'convertHTML', function() {
|
|
|
|
var cases = [
|
|
{
|
|
'html': '<p>abc</p>',
|
|
'linearModel': [
|
|
{ 'type': 'paragraph' },
|
|
'a',
|
|
'b',
|
|
'c',
|
|
{ 'type': '/paragraph' }
|
|
],
|
|
'message': 'paragraph and text'
|
|
},
|
|
{
|
|
'html': '<p><b>a</b><i>b</i><u>c</u></p>',
|
|
'linearModel': [
|
|
{ 'type': 'paragraph' },
|
|
['a', { '{"type":"textStyle/bold"}': { 'type': 'textStyle/bold' } }],
|
|
['b', { '{"type":"textStyle/italic"}': { 'type': 'textStyle/italic' } }],
|
|
['c', { '{"type":"textStyle/underline"}': { 'type': 'textStyle/underline' } }],
|
|
{ 'type': '/paragraph' }
|
|
],
|
|
'message': 'bold, italic, underline'
|
|
},
|
|
{
|
|
'html': '<img src="http://www.something.com/test.jpg">',
|
|
'linearModel': [
|
|
{ 'type': 'image', 'attributes' : { 'html/src' : 'http://www.something.com/test.jpg' } },
|
|
{ 'type' : '/image' }
|
|
],
|
|
'message': 'image'
|
|
}
|
|
];
|
|
expect(cases.length);
|
|
|
|
|
|
for ( var i = 0; i < cases.length; i++ ) {
|
|
var c = cases[i];
|
|
var convertedLinearModel = ve.dm.HTMLConverter.getLinearModel($('<div>' + c.html + '</div>')[0]);
|
|
|
|
console.log(convertedLinearModel);
|
|
console.log(c.linearModel);
|
|
|
|
deepEqual(convertedLinearModel, c.linearModel, c.message);
|
|
}
|
|
} );
|