@@ -415,6 +415,54 @@ describe('uiSortable', function() {
415
415
} ) ;
416
416
} ) ;
417
417
418
+ it ( 'should work when "helper: clone" and "placeholder" options are used together.' , function ( ) {
419
+ inject ( function ( $compile , $rootScope ) {
420
+ var element ;
421
+ element = $compile ( '<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}" class="sortable-item">{{ item }}</li></ul>' ) ( $rootScope ) ;
422
+ $rootScope . $apply ( function ( ) {
423
+ $rootScope . opts = {
424
+ helper : 'clone' ,
425
+ placeholder : 'sortable-item'
426
+ } ;
427
+ $rootScope . items = [ 'One' , 'Two' , 'Three' ] ;
428
+ } ) ;
429
+
430
+ host . append ( element ) ;
431
+
432
+ var li = element . find ( ':eq(0)' ) ;
433
+ var dy = ( 2 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
434
+ li . simulate ( 'dragAndRevert' , { dy : dy } ) ;
435
+ expect ( $rootScope . items ) . toEqual ( [ 'One' , 'Two' , 'Three' ] ) ;
436
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
437
+
438
+ li = element . find ( ':eq(0)' ) ;
439
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
440
+ li . simulate ( 'drag' , { dy : dy } ) ;
441
+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'One' , 'Three' ] ) ;
442
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
443
+
444
+ li = element . find ( ':eq(1)' ) ;
445
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
446
+ li . simulate ( 'drag' , { dy : dy } ) ;
447
+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'Three' , 'One' ] ) ;
448
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
449
+
450
+ li = element . find ( ':eq(1)' ) ;
451
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
452
+ li . simulate ( 'dragAndRevert' , { dy : dy } ) ;
453
+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'Three' , 'One' ] ) ;
454
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
455
+
456
+ li = element . find ( ':eq(1)' ) ;
457
+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
458
+ li . simulate ( 'drag' , { dy : dy } ) ;
459
+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'One' , 'Three' ] ) ;
460
+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
461
+
462
+ $ ( element ) . remove ( ) ;
463
+ } ) ;
464
+ } ) ;
465
+
418
466
} ) ;
419
467
420
468
describe ( 'Multiple sortables related' , function ( ) {
0 commit comments