mediawiki-extensions-Visual.../modules/ve-mw/test/ce/ve.ce.Surface.test.js
Ed Sanders f81c4a6f8c Update VE core submodule to master (7a128e5)
Fix failing test in handleDelete. New functionality
moves cursor to content offset.

New changes:
fb595ea Also annotate metadata in TransactionProcessor
028e442 maintenance: Simpler OOjs UI pullthrough-script
fdd5e17 Follow-up I81663929: Use grunt git-build to ensure we get the hash
58db9a8 Update OOjs UI to v0.1.0-pre (a63f03882e)
c790488 Use more standard format for displaying keyboard shortcuts
c15a6f1 Add a ve direction class to all surfaces
5c3a914 Remove old ce-surface classes
2f565b6 Fix up selection after deletion if at non-content offset
7b39328 Correct various things in rangy-position to make it work in IE

Change-Id: Ia46f4c7ded52911574b6c1104682335aaaac08d5
2014-06-30 11:21:20 -07:00

72 lines
2 KiB
JavaScript

/*!
* VisualEditor ContentEditable Surface tests.
*
* @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
QUnit.module( 've.ce.Surface' );
/* Tests */
QUnit.test( 'handleDelete', function ( assert ) {
var i,
cases = [
{
'html':
'<p>Foo</p>' +
ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent +
'<p>Bar</p>',
'range': new ve.Range( 4 ),
'operations': ['delete'],
'expectedData': function () {},
'expectedRange': new ve.Range( 5, 7 ),
'msg': 'Block transclusion is focused not deleted'
},
{
'html':
'<p>Foo</p>' +
ve.dm.mwExample.MWTransclusion.blockOpen + ve.dm.mwExample.MWTransclusion.blockContent +
'<p>Bar</p>',
'range': new ve.Range( 4 ),
'operations': ['delete', 'delete'],
'expectedData': function ( data ) {
data.splice( 5, 2 );
},
'expectedRange': new ve.Range( 6 ),
'msg': 'Block transclusion is deleted with two keypresses'
},
{
'html':
'<p>Foo</p>' +
ve.dm.mwExample.MWBlockImage.html +
'<p>Bar</p>',
'range': new ve.Range( 4 ),
'operations': ['delete'],
'expectedData': function () { },
'expectedRange': new ve.Range( 5, 14 ),
'msg': 'Block image is focused not deleted'
},
{
'html':
ve.dm.mwExample.MWBlockImage.html +
'<ul><li><p>Foo</p></li><li><p>Bar</p></li></ul>',
'range': new ve.Range( 12 ),
'operations': ['backspace'],
// TODO: This action should probably unwrap the list item as
'expectedData': function () {},
'expectedRange': new ve.Range( 12 ),
'msg': 'Backspace in a list next to a block image doesn\'t merge into the caption'
}
];
QUnit.expect( cases.length * 2 );
for ( i = 0; i < cases.length; i++ ) {
ve.test.utils.runSurfaceHandleSpecialKeyTest(
assert, cases[i].html, cases[i].range, cases[i].operations,
cases[i].expectedData, cases[i].expectedRange, cases[i].msg
);
}
} );