Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/305549
Change subject: Table move tests ...................................................................... Table move tests Change-Id: Id30b3a4fcbad02b5a24e0b892c1a4fce9c79d68f --- M tests/ui/actions/ve.ui.TableAction.test.js 1 file changed, 111 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/49/305549/1 diff --git a/tests/ui/actions/ve.ui.TableAction.test.js b/tests/ui/actions/ve.ui.TableAction.test.js index 191c487..c5acdf5 100644 --- a/tests/ui/actions/ve.ui.TableAction.test.js +++ b/tests/ui/actions/ve.ui.TableAction.test.js @@ -8,7 +8,7 @@ /* Tests */ -QUnit.test( 'create / insert / mergeCells / delete / changeCellStyle', function ( assert ) { +QUnit.test( 'create / insert / mergeCells / delete / changeCellStyle / moveRelative', function ( assert ) { var i, tableCellTail = [ { type: 'paragraph', internal: { generated: 'wrapper' } }, @@ -421,7 +421,116 @@ }, msg: 'change style to header' }, - // TODO: Write tests for simple row/column moves + { + html: ve.dm.example.annotatedTableHtml, + rangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 1, + toCol: 0, + toRow: 1 + }, + method: 'moveRelative', + args: [ 'row', 'before' ], + expectedData: function ( data ) { + var row = data.splice( 25, 25 ); + data.splice.apply( data, [ 2, 0 ].concat( row ) ); + }, + expectedRangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 0, + toCol: 0, + toRow: 0 + }, + msg: 'move row before' + }, + { + html: ve.dm.example.annotatedTableHtml, + rangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 0, + toCol: 0, + toRow: 0 + }, + method: 'moveRelative', + args: [ 'row', 'after' ], + expectedData: function ( data ) { + var row = data.splice( 25, 25 ); + data.splice.apply( data, [ 2, 0 ].concat( row ) ); + }, + expectedRangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 1, + toCol: 0, + toRow: 1 + }, + msg: 'move row after' + }, + { + html: ve.dm.example.annotatedTableHtml, + rangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 1, + fromRow: 0, + toCol: 1, + toRow: 0 + }, + method: 'moveRelative', + args: [ 'col', 'before' ], + expectedData: function ( data ) { + var cell2 = data.splice( 34, 8 ), + cell1 = data.splice( 10, 7 ); + + data.splice.apply( data, [ 26 - cell1.length, 0 ].concat( cell2 ) ); + data.splice.apply( data, [ 3, 0 ].concat( cell1 ) ); + }, + expectedRangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 0, + toCol: 0, + toRow: 0 + }, + msg: 'move column before' + }, + { + html: ve.dm.example.annotatedTableHtml, + rangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 0, + fromRow: 0, + toCol: 0, + toRow: 0 + }, + method: 'moveRelative', + args: [ 'col', 'after' ], + expectedData: function ( data ) { + var cell2 = data.splice( 26, 8 ), + cell1 = data.splice( 3, 7 ); + + data.splice.apply( data, [ 42 - cell1.length - cell2.length, 0 ].concat( cell2 ) ); + data.splice.apply( data, [ 17 - cell1.length, 0 ].concat( cell1 ) ); + }, + expectedRangeOrSelection: { + type: 'table', + tableRange: new ve.Range( 0, 52 ), + fromCol: 1, + fromRow: 0, + toCol: 1, + toRow: 0 + }, + msg: 'move column after' + }, { html: '<table><tr></tr><tr><td>A</td></tr></table>', rangeOrSelection: { -- To view, visit https://gerrit.wikimedia.org/r/305549 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id30b3a4fcbad02b5a24e0b892c1a4fce9c79d68f Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits