@@ -349,14 +349,14 @@ describe('uiSortable', function() {
349
349
350
350
it ( 'should update model when sorting between nested sortables' , function ( ) {
351
351
inject ( function ( $compile , $rootScope ) {
352
- var elementTree ;
352
+ var elementTree , li1 , li2 , dy ;
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
356
'<li ng-repeat="item in items track by $index">' ,
357
357
'<div>' ,
358
358
'<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;">' ,
360
360
'<li ng-repeat="i in item.items track by $index">' ,
361
361
'<span class="itemContent lvl2ItemContent">{{i.text}}</span>' ,
362
362
'</li>' ,
@@ -375,8 +375,8 @@ describe('uiSortable', function() {
375
375
{
376
376
text : 'Item 2' ,
377
377
items : [
378
- { text : 'Item 2.1' } ,
379
- { text : 'Item 2.2' }
378
+ { text : 'Item 2.1' , items : [ ] } ,
379
+ { text : 'Item 2.2' , items : [ ] }
380
380
]
381
381
}
382
382
] ;
@@ -388,8 +388,10 @@ describe('uiSortable', function() {
388
388
389
389
host . append ( elementTree ) ;
390
390
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 } ) ;
393
395
expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
394
396
. toEqual ( [ 'Item 1' , 'Item 2' ] ) ;
395
397
expect ( $rootScope . items . map ( function ( x ) { return x . text ; } ) )
@@ -403,6 +405,27 @@ describe('uiSortable', function() {
403
405
expect ( $rootScope . items [ 1 ] . items . map ( function ( x ) { return x . text ; } ) )
404
406
. toEqual ( listInnerContent ( elementTree . find ( '.innerList:eq(1)' ) , '.lvl2ItemContent' ) ) ;
405
407
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
+
406
429
$ ( elementTree ) . remove ( ) ;
407
430
} ) ;
408
431
} ) ;
0 commit comments