Added test that exposes bugs in prepareContentAnnotation

This commit is contained in:
Trevor Parscal 2011-11-23 23:24:05 +00:00
parent dab042b52f
commit 3ed6544fe2

View file

@ -258,7 +258,7 @@ test( 'es.DocumentModel.prepareElementAttributeChange', 4, function() {
}
} );
test( 'es.DocumentModel.prepareContentAnnotation', 1, function() {
test( 'es.DocumentModel.prepareContentAnnotation', 2, function() {
var documentModel = es.DocumentModel.newFromPlainObject( esTest.obj );
// Test 1
@ -299,6 +299,45 @@ test( 'es.DocumentModel.prepareContentAnnotation', 1, function() {
],
'prepareContentAnnotation skips over content that is already set or cleared'
);
// Test 2
deepEqual(
documentModel.prepareContentAnnotation(
new es.Range( 3, 10 ), 'set', { 'type': 'textStyle/bold' }
).getOperations(),
[
{ 'type': 'retain', 'length': 3 },
{
'type': 'annotate',
'method': 'set',
'bias': 'start',
'annotation': { 'type': 'textStyle/bold', 'hash': '{"type":"textStyle/bold"}' }
},
{ 'type': 'retain', 'length': 1 },
{
'type': 'annotate',
'method': 'set',
'bias': 'stop',
'annotation': { 'type': 'textStyle/bold', 'hash': '{"type":"textStyle/bold"}' }
},
{ 'type': 'retain', 'length': 5 },
{
'type': 'annotate',
'method': 'set',
'bias': 'start',
'annotation': { 'type': 'textStyle/bold', 'hash': '{"type":"textStyle/bold"}' }
},
{ 'type': 'retain', 'length': 1 },
{
'type': 'annotate',
'method': 'set',
'bias': 'stop',
'annotation': { 'type': 'textStyle/bold', 'hash': '{"type":"textStyle/bold"}' }
},
{ 'type': 'retain', 'length': 24 }
],
'prepareContentAnnotation works across element boundaries'
);
} );
test( 'es.DocumentModel.prepareRemoval', 11, function() {