@@ -353,11 +353,11 @@ describe('uiSortable', function() {
353
353
354
354
elementTree = $compile ( '' . concat (
355
355
'<ul ui-sortable="sortableOptions" ng-model="items" class="apps-container outterList" style="float: left;margin-left: 10px;padding-bottom: 10px;">' ,
356
- '<li ng-repeat="item in items track by $index ">' ,
356
+ '<li ng-repeat="item in items">' ,
357
357
'<div>' ,
358
358
'<span class="itemContent lvl1ItemContent">{{item.text}}</span>' ,
359
359
'<ul ui-sortable="sortableOptions" ng-model="item.items" class="apps-container innerList" style="margin-left: 10px;padding-bottom: 10px;">' ,
360
- '<li ng-repeat="i in item.items track by $index ">' ,
360
+ '<li ng-repeat="i in item.items">' ,
361
361
'<span class="itemContent lvl2ItemContent">{{i.text}}</span>' ,
362
362
'</li>' ,
363
363
'</ul>' ,
@@ -388,9 +388,9 @@ describe('uiSortable', function() {
388
388
389
389
host . append ( elementTree ) ;
390
390
391
- li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
392
391
// this should drag the item out of the list and
393
392
// the item should return back to its original position
393
+ li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
394
394
li1 . simulate ( 'drag' , { dx : - 200 , moves : 30 } ) ;
395
395
expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
396
396
. toEqual ( [ 'Item 1' , 'Item 2' ] ) ;
@@ -405,6 +405,8 @@ describe('uiSortable', function() {
405
405
expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
406
406
. toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
407
407
408
+ // this should drag the item from the inner list and
409
+ // drop it to the outter list
408
410
li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
409
411
li2 = elementTree . find ( '> li:last' ) ;
410
412
dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
@@ -426,6 +428,25 @@ describe('uiSortable', function() {
426
428
expect ( $rootScope . items [ 2 ] . items . map ( function ( x ) { return x . text ; } ) )
427
429
. toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(2)' ) , '.lvl2ItemContent' ) ) ;
428
430
431
+ // this should drag the item from the outter list and
432
+ // drop it to the inner list
433
+ li1 = elementTree . find ( '> li:first' ) ;
434
+ li2 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
435
+ dy = - EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
436
+ li1 . simulate ( 'drag' , { dy : dy } ) ;
437
+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
438
+ . toEqual ( [ 'Item 2.2' , 'Item 2' ] ) ;
439
+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
440
+ . toEqual ( listInnerContent ( elementTree , '.lvl1ItemContent' ) ) ;
441
+ expect ( $rootScope . items [ 0 ] . items . map ( function ( x ) { return x . text ; } ) )
442
+ . toEqual ( [ ] ) ;
443
+ expect ( $rootScope . items [ 0 ] . items . map ( function ( x ) { return x . text ; } ) )
444
+ . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(0)' ) , '.lvl2ItemContent' ) ) ;
445
+ expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
446
+ . toEqual ( [ 'Item 1' , 'Item 2.1' ] ) ;
447
+ expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
448
+ . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
449
+
429
450
$ ( elementTree ) . remove ( ) ;
430
451
} ) ;
431
452
} ) ;
0 commit comments