Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit ead6cc1

Browse files
committed
test(sortable): add test for appendTo when using a jQuery object
1 parent 2592b4a commit ead6cc1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/sortable.e2e.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,36 @@ describe('uiSortable', function() {
476476
});
477477
});
478478

479+
it('should work when "helper: clone" and "appendTo [jQuery object]" options are used together', function() {
480+
inject(function($compile, $rootScope) {
481+
var element;
482+
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);
483+
$rootScope.$apply(function() {
484+
$rootScope.opts = {
485+
helper: 'clone',
486+
appendTo: angular.element(document.body)
487+
};
488+
$rootScope.items = ['One', 'Two', 'Three'];
489+
});
490+
491+
host.append(element);
492+
493+
var li = element.find(':eq(1)');
494+
var dy = (1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
495+
li.simulate('drag', { dy: dy });
496+
expect($rootScope.items).toEqual(['One', 'Three', 'Two']);
497+
expect($rootScope.items).toEqual(listContent(element));
498+
499+
li = element.find(':eq(2)');
500+
dy = -(1 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
501+
li.simulate('drag', { dy: dy });
502+
expect($rootScope.items).toEqual(['One', 'Two', 'Three']);
503+
expect($rootScope.items).toEqual(listContent(element));
504+
505+
$(element).remove();
506+
});
507+
});
508+
479509
it('should work when "helper: clone" and "placeholder" options are used together.', function() {
480510
inject(function($compile, $rootScope) {
481511
var element;

0 commit comments

Comments
 (0)