2013-10-05 10:27:39 +00:00
|
|
|
/*!
|
2014-07-21 18:02:12 +00:00
|
|
|
* VisualEditor ContentEditable MediaWiki-specific Surface tests.
|
2013-10-05 10:27:39 +00:00
|
|
|
*
|
2016-01-03 22:56:59 +00:00
|
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
2013-10-05 10:27:39 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2015-05-17 09:37:34 +00:00
|
|
|
QUnit.module( 've.ce.Surface (MW)', ve.test.utils.mwEnvironment );
|
2013-10-05 10:27:39 +00:00
|
|
|
|
|
|
|
/* Tests */
|
|
|
|
|
2014-10-10 09:20:35 +00:00
|
|
|
QUnit.test( 'handleLinearDelete', function ( assert ) {
|
2013-10-05 10:27:39 +00:00
|
|
|
var i,
|
2013-12-02 14:05:24 +00:00
|
|
|
blocklength = ve.dm.mwExample.MWBlockImage.data.length,
|
2013-10-05 10:27:39 +00:00
|
|
|
cases = [
|
2014-09-18 20:15:24 +00:00
|
|
|
// This asserts that getRelativeRange (via getRelativeOffset) doesn't try to
|
|
|
|
// enter a handleOwnChildren node
|
2013-12-03 17:28:04 +00:00
|
|
|
{
|
2016-03-22 14:38:33 +00:00
|
|
|
htmlOrDoc:
|
2013-12-03 17:28:04 +00:00
|
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
|
|
'<ul><li><p>Foo</p></li><li><p>Bar</p></li></ul>',
|
2016-03-22 14:38:33 +00:00
|
|
|
rangeOrSelection: new ve.Range( blocklength + 3 ),
|
|
|
|
keys: [ 'BACKSPACE' ],
|
2013-12-02 14:05:24 +00:00
|
|
|
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' } }
|
|
|
|
);
|
|
|
|
},
|
2016-03-22 14:38:33 +00:00
|
|
|
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
|
2014-08-22 20:50:48 +00:00
|
|
|
msg: 'Backspace in a list next to a block image doesn\'t merge into the caption'
|
2013-12-02 14:05:24 +00:00
|
|
|
},
|
|
|
|
{
|
2016-03-22 14:38:33 +00:00
|
|
|
htmlOrDoc:
|
2013-12-02 14:05:24 +00:00
|
|
|
ve.dm.mwExample.MWBlockImage.html +
|
|
|
|
'<ul><li><p></p></li></ul>',
|
2016-03-22 14:38:33 +00:00
|
|
|
rangeOrSelection: new ve.Range( blocklength + 3 ),
|
|
|
|
keys: [ 'BACKSPACE' ],
|
2013-12-02 14:05:24 +00:00
|
|
|
expectedData: function ( data ) {
|
|
|
|
data.splice(
|
|
|
|
blocklength, 6,
|
|
|
|
{ type: 'paragraph' },
|
|
|
|
{ type: '/paragraph' }
|
|
|
|
);
|
|
|
|
},
|
2016-03-22 14:38:33 +00:00
|
|
|
expectedRangeOrSelection: new ve.Range( blocklength + 1 ),
|
2013-12-02 14:05:24 +00:00
|
|
|
msg: 'Backspace in an empty list next to a block image removes the list'
|
2013-10-05 10:27:39 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
QUnit.expect( cases.length * 2 );
|
|
|
|
|
|
|
|
for ( i = 0; i < cases.length; i++ ) {
|
2013-12-02 14:51:52 +00:00
|
|
|
ve.test.utils.runSurfaceHandleSpecialKeyTest(
|
2016-03-22 14:38:33 +00:00
|
|
|
assert, cases[ i ].htmlOrDoc, cases[ i ].rangeOrSelection, cases[ i ].keys,
|
|
|
|
cases[ i ].expectedData, cases[ i ].expectedRangeOrSelection, cases[ i ].msg
|
2013-10-05 10:27:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|