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
|
|
|
*
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 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
|
|
|
{
|
2014-08-22 20:50:48 +00:00
|
|
|
html:
|
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>',
|
2013-12-02 14:05:24 +00:00
|
|
|
range: new ve.Range( blocklength + 3 ),
|
2015-07-22 22:13:09 +00:00
|
|
|
operations: [ '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' } }
|
|
|
|
);
|
|
|
|
},
|
2015-03-25 15:00:40 +00:00
|
|
|
expectedSelection: {
|
|
|
|
type: 'linear',
|
2013-12-02 14:05:24 +00:00
|
|
|
range: new ve.Range( blocklength + 1 )
|
2015-03-25 15:00:40 +00:00
|
|
|
},
|
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
|
|
|
},
|
|
|
|
{
|
|
|
|
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'
|
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(
|
2015-08-19 17:33:02 +00:00
|
|
|
assert, cases[ i ].html, cases[ i ].range, cases[ i ].operations,
|
|
|
|
cases[ i ].expectedData, cases[ i ].expectedSelection, cases[ i ].msg
|
2013-10-05 10:27:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|