@@ -353,11 +353,11 @@ describe('uiSortable', function() {
353353
354354 elementTree = $compile ( '' . concat (
355355 '<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">' ,
357357 '<div>' ,
358358 '<span class="itemContent lvl1ItemContent">{{item.text}}</span>' ,
359359 '<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">' ,
361361 '<span class="itemContent lvl2ItemContent">{{i.text}}</span>' ,
362362 '</li>' ,
363363 '</ul>' ,
@@ -388,9 +388,9 @@ describe('uiSortable', function() {
388388
389389 host . append ( elementTree ) ;
390390
391- li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
392391 // this should drag the item out of the list and
393392 // the item should return back to its original position
393+ li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
394394 li1 . simulate ( 'drag' , { dx : - 200 , moves : 30 } ) ;
395395 expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
396396 . toEqual ( [ 'Item 1' , 'Item 2' ] ) ;
@@ -405,6 +405,8 @@ describe('uiSortable', function() {
405405 expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
406406 . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
407407
408+ // this should drag the item from the inner list and
409+ // drop it to the outter list
408410 li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
409411 li2 = elementTree . find ( '> li:last' ) ;
410412 dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
@@ -426,6 +428,25 @@ describe('uiSortable', function() {
426428 expect ( $rootScope . items [ 2 ] . items . map ( function ( x ) { return x . text ; } ) )
427429 . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(2)' ) , '.lvl2ItemContent' ) ) ;
428430
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+
429450 $ ( elementTree ) . remove ( ) ;
430451 } ) ;
431452 } ) ;
0 commit comments