Add more tests for ve.ce.Surface#onContentChange

Change-Id: I8ad12ca086d4dadce82a954ee015af2cc3bbd7cc
This commit is contained in:
Ed Sanders 2013-09-27 11:55:43 +01:00
parent f3899c4041
commit 686564246d

View file

@ -116,6 +116,51 @@ QUnit.test( 'handleDelete', function ( assert ) {
QUnit.test( 'onContentChange', function ( assert ) {
var i,
cases = [
{
'prevHtml': '<p></p>',
'prevRange': new ve.Range( 1 ),
'nextHtml': '<p>A</p>',
'nextRange': new ve.Range( 2 ),
'expectedOps': [
[
{ 'type': 'retain', 'length': 1 },
{
'type': 'replace',
'insert': [ 'A' ],
'remove': []
},
{ 'type': 'retain', 'length': 3 }
]
],
'msg': 'Simple insertion into empty paragraph'
},
{
'prevHtml': '<p>A</p>',
'prevRange': new ve.Range( 1, 2 ),
'nextHtml': '<p>B</p>',
'nextRange': new ve.Range( 2 ),
'expectedOps': [
[
{ 'type': 'retain', 'length': 1 },
{
'type': 'replace',
'insert': [ 'B' ],
'remove': []
},
{ 'type': 'retain', 'length': 4 }
],
[
{ 'type': 'retain', 'length': 2 },
{
'type': 'replace',
'insert': [],
'remove': [ 'A' ]
},
{ 'type': 'retain', 'length': 3 }
]
],
'msg': 'Simple replace'
},
{
'prevHtml': '<p><a href="Foo">A</a><a href="Bar">FooX?</a></p>',
'prevRange': new ve.Range( 5, 6 ),