diff --git a/test/sortable.e2e.multi.spec.js b/test/sortable.e2e.multi.spec.js index a9cebae..5aac598 100644 --- a/test/sortable.e2e.multi.spec.js +++ b/test/sortable.e2e.multi.spec.js @@ -64,6 +64,45 @@ describe('uiSortable', function() { }); }); + it('should update model when sorting between sortables of different scopes', function() { + inject(function($compile, $rootScope) { + var elementTop, elementBottom, + wrapperTop, wrapperBottom, + itemsTop, itemsBottom; + wrapperTop = $compile('
')($rootScope); + wrapperBottom = $compile('
')($rootScope); + + host.append(wrapperTop).append(wrapperBottom).append('
'); + $rootScope.$apply(function() { + wrapperTop.scope().itemsTop = itemsTop = ['Top One', 'Top Two', 'Top Three']; + wrapperBottom.scope().itemsBottom = itemsBottom = ['Bottom One', 'Bottom Two', 'Bottom Three']; + $rootScope.opts = { connectWith: '.cross-sortable' }; + }); + + elementTop = wrapperTop.find('> [ui-sortable]'); + elementBottom = wrapperBottom.find('> [ui-sortable]'); + + var li1 = elementTop.find(':eq(0)'); + var li2 = elementBottom.find(':eq(0)'); + simulateElementDrag(li1, li2, 'below'); + expect(itemsTop).toEqual(['Top Two', 'Top Three']); + expect(itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']); + expect(itemsTop).toEqual(listContent(elementTop)); + expect(itemsBottom).toEqual(listContent(elementBottom)); + + li1 = elementBottom.find(':eq(1)'); + li2 = elementTop.find(':eq(1)'); + simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 }); + expect(itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']); + expect(itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']); + expect(itemsTop).toEqual(listContent(elementTop)); + expect(itemsBottom).toEqual(listContent(elementBottom)); + + $(elementTop).remove(); + $(elementBottom).remove(); + }); + }); + it('should update model when sorting a "falsy" item between sortables', function() { inject(function($compile, $rootScope) { var elementTop, elementBottom; diff --git a/test/sortable.test-helper.js b/test/sortable.test-helper.js index 4da4d45..5728d49 100644 --- a/test/sortable.test-helper.js +++ b/test/sortable.test-helper.js @@ -78,4 +78,7 @@ angular.module('ui.sortable.testHelper', []) simulateElementDrag: simulateElementDrag, hasUndefinedProperties: hasUndefinedProperties }; + }) + .controller('dummyController', function ($scope) { + $scope.testItems = ['One', 'Two', 'Three']; });