@@ -167,36 +167,36 @@ describe('uiSortable', function() {
167
167
host = null ;
168
168
} ) ;
169
169
170
- // it('should cancel sorting of node "Two"', function() {
171
- // inject(function($compile, $rootScope) {
172
- // var element;
173
- // element = $compile('<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li></ul>')($rootScope);
174
- // $rootScope.$apply(function() {
175
- // $rootScope.opts = {
176
- // update: function(e, ui) {
177
- // if (ui.item.scope().item === "Two") {
178
- // ui.item.parent(). sortable(' cancel' );
179
- // }
180
- // }
181
- // };
182
- // $rootScope.items = ["One", "Two", "Three"];
183
- // });
184
-
185
- // host.append(element);
186
-
187
- // var li = element.find(':eq(1)');
188
- // var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
189
- // li.simulate('drag', { dy: dy });
190
- // expect($rootScope.items).toEqual(["One", "Two", "Three"]);
191
-
192
- // li = element.find(':eq(0)');
193
- // dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
194
- // li.simulate('drag', { dy: dy });
195
- // expect($rootScope.items).toEqual(["Two", "Three", "One"]);
196
-
197
- // $(element).remove();
198
- // });
199
- // });
170
+ it ( 'should cancel sorting of node "Two"' , function ( ) {
171
+ inject ( function ( $compile , $rootScope ) {
172
+ var element ;
173
+ element = $compile ( '<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li></ul>' ) ( $rootScope ) ;
174
+ $rootScope . $apply ( function ( ) {
175
+ $rootScope . opts = {
176
+ update : function ( e , ui ) {
177
+ if ( ui . item . scope ( ) . item === "Two" ) {
178
+ ui . item . sortable . cancel ( ) ;
179
+ }
180
+ }
181
+ } ;
182
+ $rootScope . items = [ "One" , "Two" , "Three" ] ;
183
+ } ) ;
184
+
185
+ host . append ( element ) ;
186
+
187
+ var li = element . find ( ':eq(1)' ) ;
188
+ var dy = ( 1 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
189
+ li . simulate ( 'drag' , { dy : dy } ) ;
190
+ expect ( $rootScope . items ) . toEqual ( [ "One" , "Two" , "Three" ] ) ;
191
+
192
+ li = element . find ( ':eq(0)' ) ;
193
+ dy = ( 2 + EXTRA_DY_PERCENTAGE ) * li . outerHeight ( ) ;
194
+ li . simulate ( 'drag' , { dy : dy } ) ;
195
+ expect ( $rootScope . items ) . toEqual ( [ "Two" , "Three" , "One" ] ) ;
196
+
197
+ $ ( element ) . remove ( ) ;
198
+ } ) ;
199
+ } ) ;
200
200
201
201
it ( 'should update model from update() callback' , function ( ) {
202
202
inject ( function ( $compile , $rootScope ) {
0 commit comments