@@ -349,14 +349,14 @@ describe('uiSortable', function() {
349349
350350 it ( 'should update model when sorting between nested sortables' , function ( ) {
351351 inject ( function ( $compile , $rootScope ) {
352- var elementTree ;
352+ var elementTree , li1 , li2 , dy ;
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;">' ,
356356 '<li ng-repeat="item in items track by $index">' ,
357357 '<div>' ,
358358 '<span class="itemContent lvl1ItemContent">{{item.text}}</span>' ,
359- '<ul ui-sortable="sortableOptions" ng-model="item.items" class="apps-container innerList" style="float: left; margin-left: 10px;padding-bottom: 10px;">' ,
359+ '<ul ui-sortable="sortableOptions" ng-model="item.items" class="apps-container innerList" style="margin-left: 10px;padding-bottom: 10px;">' ,
360360 '<li ng-repeat="i in item.items track by $index">' ,
361361 '<span class="itemContent lvl2ItemContent">{{i.text}}</span>' ,
362362 '</li>' ,
@@ -375,8 +375,8 @@ describe('uiSortable', function() {
375375 {
376376 text : 'Item 2' ,
377377 items : [
378- { text : 'Item 2.1' } ,
379- { text : 'Item 2.2' }
378+ { text : 'Item 2.1' , items : [ ] } ,
379+ { text : 'Item 2.2' , items : [ ] }
380380 ]
381381 }
382382 ] ;
@@ -388,8 +388,10 @@ describe('uiSortable', function() {
388388
389389 host . append ( elementTree ) ;
390390
391- var li = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
392- li . simulate ( 'drag' , { dx : - 200 , moves : 30 } ) ;
391+ li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
392+ // this should drag the item out of the list and
393+ // the item should return back to its original position
394+ li1 . simulate ( 'drag' , { dx : - 200 , moves : 30 } ) ;
393395 expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
394396 . toEqual ( [ 'Item 1' , 'Item 2' ] ) ;
395397 expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
@@ -403,6 +405,27 @@ describe('uiSortable', function() {
403405 expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
404406 . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
405407
408+ li1 = elementTree . find ( '.innerList:last' ) . find ( ':last' ) ;
409+ li2 = elementTree . find ( '> li:last' ) ;
410+ dy = EXTRA_DY_PERCENTAGE * li1 . outerHeight ( ) + ( li2 . position ( ) . top - li1 . position ( ) . top ) ;
411+ li1 . simulate ( 'drag' , { dy : dy } ) ;
412+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
413+ . toEqual ( [ 'Item 1' , 'Item 2.2' , 'Item 2' ] ) ;
414+ expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
415+ . toEqual ( listInnerContent ( elementTree , '.lvl1ItemContent' ) ) ;
416+ expect ( $rootScope . items [ 0 ] . items . map ( function ( x ) { return x . text ; } ) )
417+ . toEqual ( [ ] ) ;
418+ expect ( $rootScope . items [ 0 ] . items . map ( function ( x ) { return x . text ; } ) )
419+ . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(0)' ) , '.lvl2ItemContent' ) ) ;
420+ expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
421+ . toEqual ( [ ] ) ;
422+ expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
423+ . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
424+ expect ( $rootScope . items [ 2 ] . items . map ( function ( x ) { return x . text ; } ) )
425+ . toEqual ( [ 'Item 2.1' ] ) ;
426+ expect ( $rootScope . items [ 2 ] . items . map ( function ( x ) { return x . text ; } ) )
427+ . toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(2)' ) , '.lvl2ItemContent' ) ) ;
428+
406429 $ ( elementTree ) . remove ( ) ;
407430 } ) ;
408431 } ) ;
0 commit comments