mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 00:55:00 +00:00
9bcc61e195
New changes: 95589a6 test: Add a Rakefile for new CI requirement 1a4497e ve.ui.DialogTool: Do not require that a command is set cbf1bff ve.ui.Tool: Fix documentation for getCommandName 530022d Localisation updates from https://translatewiki.net. 9529093 Update OOjs UI to v0.13.2 b8d6c15 Add icon: Rename 'insert' to 'add' 2f3015b Update OOjs to v1.1.10 78ceb18 Fix deletion inside a structural node at start/end of document ce3e9a4 ve.utils: Use binarySearch from OOjs Local change: * MW test cases for new structural deletion logic Bug: T52250 Change-Id: I643449c1fa08ea12c8c3aa13f4a4b97d8876990d
71 lines
2 KiB
JavaScript
71 lines
2 KiB
JavaScript
/*!
|
|
* VisualEditor ContentEditable MediaWiki-specific Surface tests.
|
|
*
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
QUnit.module( 've.ce.Surface (MW)', ve.test.utils.mwEnvironment );
|
|
|
|
/* Tests */
|
|
|
|
QUnit.test( 'handleLinearDelete', function ( assert ) {
|
|
var i,
|
|
blocklength = ve.dm.mwExample.MWBlockImage.data.length,
|
|
cases = [
|
|
// This asserts that getRelativeRange (via getRelativeOffset) doesn't try to
|
|
// enter a handleOwnChildren node
|
|
{
|
|
html:
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
'<ul><li><p>Foo</p></li><li><p>Bar</p></li></ul>',
|
|
range: new ve.Range( blocklength + 3 ),
|
|
operations: [ 'backspace' ],
|
|
expectedData: function ( data ) {
|
|
// remove the first list item, and replace its wrapped paragraph outside
|
|
// the start of the list
|
|
data.splice(
|
|
blocklength, 8,
|
|
{ type: 'paragraph' },
|
|
'F', 'o', 'o',
|
|
{ type: '/paragraph' },
|
|
{ type: 'list', attributes: { style: 'bullet' } }
|
|
);
|
|
},
|
|
expectedSelection: {
|
|
type: 'linear',
|
|
range: new ve.Range( blocklength + 1 )
|
|
},
|
|
msg: 'Backspace in a list next to a block image doesn\'t merge into the caption'
|
|
},
|
|
{
|
|
html:
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
'<ul><li><p></p></li></ul>',
|
|
range: new ve.Range( blocklength + 3 ),
|
|
operations: [ 'backspace' ],
|
|
expectedData: function ( data ) {
|
|
data.splice(
|
|
blocklength, 6,
|
|
{ type: 'paragraph' },
|
|
{ type: '/paragraph' }
|
|
);
|
|
},
|
|
expectedSelection: {
|
|
type: 'linear',
|
|
range: new ve.Range( blocklength + 1 )
|
|
},
|
|
msg: 'Backspace in an empty list next to a block image removes the list'
|
|
}
|
|
];
|
|
|
|
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 ].expectedSelection, cases[ i ].msg
|
|
);
|
|
}
|
|
} );
|