1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
/*!
* VisualEditor UserInterface Actions IndentationAction tests.
*
* @copyright See AUTHORS.txt
*/
QUnit.module( 've.ui.IndentationAction' );
/* Tests */
QUnit.test( 'increase/decrease', ( assert ) => {
const cases = [
{
rangeOrSelection: new ve.Range( 13, 14 ),
method: 'increase',
expectedRangeOrSelection: new ve.Range( 13, 14 ),
expectedData: function ( data ) {
data.splice( 20, 0, { type: '/listItem' }, { type: '/list' } );
data.splice( 10, 1, { type: 'list', attributes: { style: 'bullet' } } );
},
undo: true,
msg: 'increase indentation on Item 2'
},
{
rangeOrSelection: new ve.Range( 14, 16 ),
method: 'decrease',
expectedRangeOrSelection: new ve.Range( 14, 16 ),
expectedData: function ( data ) {
data.splice( 11, 2, { type: '/list' }, { type: 'paragraph' } );
data.splice( 19, 2, { type: '/paragraph' }, { type: 'list', attributes: { style: 'bullet' } } );
},
undo: true,
msg: 'decrease indentation on partial selection of list item "Item 2"'
},
{
rangeOrSelection: new ve.Range( 3, 19 ),
method: 'decrease',
expectedRangeOrSelection: new ve.Range( 1, 15 ),
expectedData: function ( data ) {
data.splice( 0, 2 );
data.splice( 8, 2 );
data.splice( 16, 1, { type: 'list', attributes: { style: 'bullet' } } );
delete data[ 0 ].internal;
delete data[ 8 ].internal;
},
undo: true,
msg: 'decrease indentation on Items 1 & 2'
},
{
rangeOrSelection: new ve.Range( 3, 19 ),
method: 'increase',
expectedRangeOrSelection: new ve.Range( 5, 21 ),
expectedData: function ( data ) {
data.splice( 0, 0, { type: 'list', attributes: { style: 'bullet' } }, { type: 'listItem' } );
data.splice( 23, 0, { type: '/list' }, { type: '/listItem' } );
},
undo: true,
msg: 'increase indentation on Items 1 & 2'
},
{
html: '<ul><li><table><tr><td>A</td></tr></table></li></ul>',
rangeOrSelection: new ve.Range( 2 ),
method: 'decrease',
expectedRangeOrSelection: new ve.Range( 0 ),
expectedData: function ( data ) {
data.splice( 13, 2 );
data.splice( 0, 2 );
},
undo: true,
msg: 'decrease indentation in slug'
},
{
html: '<ul><li><table><tr><td>A</td></tr></table></li></ul>',
rangeOrSelection: new ve.Range( 2 ),
method: 'increase',
expectedRangeOrSelection: new ve.Range( 4 ),
expectedData: function ( data ) {
data.splice( 15, 0, { type: '/listItem' }, { type: '/list' } );
data.splice( 0, 0, { type: 'list', attributes: { style: 'bullet' } }, { type: 'listItem' } );
},
undo: true,
msg: 'increase indentation in slug'
},
{
// * a
// ** b
// * c
html: '<ul><li><p>a</p><ul><li><p>b</p></li></ul></li><li><p>c</p></li></ul>',
rangeOrSelection: new ve.Range( 9 ),
method: 'decrease',
expectedRangeOrSelection: new ve.Range( 9 ),
expectedData: function ( data ) {
data.splice( 11, 2 );
data.splice( 5, 1, { type: '/listItem' } );
},
undo: true,
msg: 'decrease indentation of double-indented item'
},
{
html: '<table><tr><td>A</td></tr></table>',
rangeOrSelection: {
type: 'table',
tableRange: new ve.Range( 0, 13 ),
fromCol: 0,
fromRow: 0,
toCol: 0,
toRow: 0
},
method: 'increase',
expectedRangeOrSelection: {
type: 'table',
tableRange: new ve.Range( 0, 13 ),
fromCol: 0,
fromRow: 0,
toCol: 0,
toRow: 0
},
expectedData: function () {},
msg: 'no-op on a table selection'
}
];
cases.forEach( ( caseItem ) => {
ve.test.utils.runActionTest(
assert,
{
actionName: 'indentation',
html: ve.dm.example.isolationHtml,
...caseItem
}
);
} );
} );
|