@@ -220,7 +220,7 @@ describe('Tile drag and drop', () => {
220220 expect ( dropTarget . position ) . to . equal ( 4 ) ;
221221 } ) ;
222222
223- it ( 'should adjust reflected tiles positions when using slide action ' , async ( ) => {
223+ it ( 'should adjust reflected tiles positions' , async ( ) => {
224224 const draggedTile = getTile ( 0 ) ;
225225 const dropTarget = getTile ( 1 ) ;
226226
@@ -246,7 +246,7 @@ describe('Tile drag and drop', () => {
246246 expect ( dropTarget . position ) . to . equal ( 0 ) ;
247247 } ) ;
248248
249- it ( 'should not change order when dragging a tile onto itself when using slide action ' , async ( ) => {
249+ it ( 'should not change order when dragging a tile onto itself' , async ( ) => {
250250 const initialTiles = tileManager . tiles ;
251251 const tile = getTile ( 0 ) ;
252252
@@ -260,38 +260,7 @@ describe('Tile drag and drop', () => {
260260 expect ( tileManager . tiles [ 1 ] . id ) . to . equal ( 'tile1' ) ;
261261 } ) ;
262262
263- it ( 'should swap the dragged tile with the drop target when using swap action' , async ( ) => {
264- const draggedTile = getTile ( 0 ) ;
265- const dropTarget = getTile ( 4 ) ;
266-
267- expect ( tileManager . tiles [ 0 ] . id ) . to . equal ( 'tile0' ) ;
268- expect ( tileManager . tiles [ 4 ] . id ) . to . equal ( 'tile4' ) ;
269- expect ( draggedTile . position ) . to . equal ( 0 ) ;
270- expect ( dropTarget . position ) . to . equal ( 4 ) ;
271-
272- await dragAndDrop ( draggedTile , dropTarget ) ;
273-
274- expect ( tileManager . tiles [ 0 ] . id ) . to . equal ( 'tile4' ) ;
275- expect ( tileManager . tiles [ 4 ] . id ) . to . equal ( 'tile0' ) ;
276- expect ( draggedTile . position ) . to . equal ( 4 ) ;
277- expect ( dropTarget . position ) . to . equal ( 0 ) ;
278- } ) ;
279-
280- it ( 'should not change order when dragging a tile onto itself when using swap action' , async ( ) => {
281- const initialTiles = tileManager . tiles ;
282- const tile = getTile ( 0 ) ;
283-
284- expect ( tileManager . tiles [ 0 ] . id ) . to . equal ( 'tile0' ) ;
285- expect ( tileManager . tiles [ 1 ] . id ) . to . equal ( 'tile1' ) ;
286-
287- await dragAndDrop ( tile , tile ) ;
288-
289- expect ( tileManager . tiles ) . eql ( initialTiles ) ;
290- expect ( tileManager . tiles [ 0 ] . id ) . to . equal ( 'tile0' ) ;
291- expect ( tileManager . tiles [ 1 ] . id ) . to . equal ( 'tile1' ) ;
292- } ) ;
293-
294- it ( 'should swap positions only once while dragging smaller tile over bigger tile when using slide action' , async ( ) => {
263+ it ( 'should swap positions only once while dragging smaller tile over bigger tile' , async ( ) => {
295264 tileManager . columnCount = 5 ;
296265 const draggedTile = getTile ( 0 ) ;
297266 const dropTarget = getTile ( 1 ) ;
@@ -320,6 +289,71 @@ describe('Tile drag and drop', () => {
320289 simulateLostPointerCapture ( draggedTile ) ;
321290 await elementUpdated ( draggedTile ) ;
322291 } ) ;
292+
293+ it ( 'should swap positions properly when row, column and span are specified' , async ( ) => {
294+ const draggedTile = getTile ( 0 ) ;
295+ const dropTarget = getTile ( 1 ) ;
296+
297+ draggedTile . colSpan = 2 ;
298+ draggedTile . rowSpan = 2 ;
299+ draggedTile . colStart = 3 ;
300+ draggedTile . rowStart = 3 ;
301+
302+ await elementUpdated ( tileManager ) ;
303+
304+ tileManager . tiles . forEach ( ( tile , index ) => {
305+ expect ( tile . id ) . to . equal ( `tile${ index } ` ) ;
306+ } ) ;
307+ expect ( draggedTile . position ) . to . equal ( 0 ) ;
308+ expect ( dropTarget . position ) . to . equal ( 1 ) ;
309+
310+ await dragAndDrop ( draggedTile , dropTarget ) ;
311+
312+ const expectedIdsAfterDrag = [
313+ 'tile1' ,
314+ 'tile0' ,
315+ 'tile2' ,
316+ 'tile3' ,
317+ 'tile4' ,
318+ ] ;
319+ tileManager . tiles . forEach ( ( tile , index ) => {
320+ expect ( tile . id ) . to . equal ( expectedIdsAfterDrag [ index ] ) ;
321+ } ) ;
322+ expect ( draggedTile . position ) . to . equal ( 1 ) ;
323+ expect ( draggedTile . colSpan ) . to . equal ( 2 ) ;
324+ expect ( draggedTile . rowSpan ) . to . equal ( 2 ) ;
325+ expect ( draggedTile . colStart ) . to . be . null ;
326+ expect ( draggedTile . rowStart ) . to . be . null ;
327+ expect ( dropTarget . position ) . to . equal ( 0 ) ;
328+ expect ( dropTarget . colSpan ) . to . equal ( 1 ) ;
329+ expect ( dropTarget . rowSpan ) . to . equal ( 1 ) ;
330+ } ) ;
331+
332+ it ( 'should adjust positions properly when both tiles have columns and rows specified' , async ( ) => {
333+ const draggedTile = getTile ( 0 ) ;
334+ const dropTarget = getTile ( 1 ) ;
335+
336+ draggedTile . colStart = 2 ;
337+ draggedTile . rowStart = 2 ;
338+
339+ dropTarget . colStart = 3 ;
340+ dropTarget . rowStart = 3 ;
341+
342+ await elementUpdated ( tileManager ) ;
343+
344+ expect ( draggedTile . position ) . to . equal ( 0 ) ;
345+ expect ( dropTarget . position ) . to . equal ( 1 ) ;
346+
347+ await dragAndDrop ( draggedTile , dropTarget ) ;
348+
349+ expect ( draggedTile . position ) . to . equal ( 1 ) ;
350+ expect ( draggedTile . colStart ) . to . equal ( 3 ) ;
351+ expect ( draggedTile . rowStart ) . to . equal ( 3 ) ;
352+
353+ expect ( dropTarget . position ) . to . equal ( 0 ) ;
354+ expect ( dropTarget . colStart ) . to . equal ( 2 ) ;
355+ expect ( dropTarget . rowStart ) . to . equal ( 3 ) ;
356+ } ) ;
323357 } ) ;
324358
325359 describe ( 'Tile header drag' , ( ) => {
@@ -333,7 +367,7 @@ describe('Tile drag and drop', () => {
333367 tile : IgcTileComponent ,
334368 target : IgcTileComponent
335369 ) {
336- const header = tile . renderRoot . querySelector ( '[part="title "]' ) ! ;
370+ const header = tile . renderRoot . querySelector ( '[part="header "]' ) ! ;
337371 const { x, y } = getCenterPoint ( target ) ;
338372
339373 simulatePointerDown ( header ) ;
0 commit comments