@@ -374,6 +374,47 @@ describe('uiSortable', function() {
374374 } ) ;
375375 } ) ;
376376
377+ it ( 'should work when "helper: clone" option is used and a drag is reverted' , function ( ) {
378+ inject ( function ( $compile , $rootScope ) {
379+ var element ;
380+ 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 ) ;
381+ $rootScope . $apply ( function ( ) {
382+ $rootScope . opts = {
383+ helper : 'clone' ,
384+ } ;
385+ $rootScope . items = [ 'One' , 'Two' , 'Three' ] ;
386+ } ) ;
387+
388+ host . append ( element ) ;
389+
390+ var li = element . find ( ':eq(0)' ) ;
391+ var dy = ( 2 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
392+ li . simulate ( 'dragAndRevert' , { dy : dy } ) ;
393+ expect ( $rootScope . items ) . toEqual ( [ 'One' , 'Two' , 'Three' ] ) ;
394+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
395+
396+ li = element . find ( ':eq(0)' ) ;
397+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
398+ li . simulate ( 'drag' , { dy : dy } ) ;
399+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'One' , 'Three' ] ) ;
400+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
401+
402+ li = element . find ( ':eq(1)' ) ;
403+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
404+ li . simulate ( 'drag' , { dy : dy } ) ;
405+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'Three' , 'One' ] ) ;
406+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
407+
408+ li = element . find ( ':eq(1)' ) ;
409+ dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
410+ li . simulate ( 'drag' , { dy : dy } ) ;
411+ expect ( $rootScope . items ) . toEqual ( [ 'Two' , 'One' , 'Three' ] ) ;
412+ expect ( $rootScope . items ) . toEqual ( listContent ( element ) ) ;
413+
414+ $ ( element ) . remove ( ) ;
415+ } ) ;
416+ } ) ;
417+
377418 } ) ;
378419
379420 describe ( 'Multiple sortables related' , function ( ) {
0 commit comments