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

Commit 09c0112

Browse files
committed
test(e2e.nested): test directly nested sortables
1 parent 6a92dfe commit 09c0112

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/sortable.e2e.nested.spec.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,59 @@ describe('uiSortable', function() {
128128
});
129129
});
130130

131+
it('should update model when sorting between drectly nested sortables', function() {
132+
inject(function($compile, $rootScope) {
133+
var elementTree, li1, li2;
134+
135+
elementTree = $compile(''.concat(
136+
'<div ui-sortable="sortableOptions" ng-model="items" class="nested-sortable outterList" style="float: left;margin-left: 10px;padding-bottom: 10px;">',
137+
'<div ui-sortable="innerSortableOptions" ng-model="item.items" class="nested-sortable innerList" ng-repeat="item in items">',
138+
'<div class="itemContent lvl1ItemContent">{{item.text}}</div>',
139+
'<div ng-repeat="i in item.items" style="margin-left: 10px;padding-bottom: 10px;">',
140+
'<div class="itemContent lvl2ItemContent">{{i.text}}</div>',
141+
'</div>',
142+
'</div>',
143+
'</div>',
144+
'<div style="clear: both;"></div>'))($rootScope);
145+
146+
$rootScope.$apply(function() {
147+
$rootScope.items = [
148+
{
149+
text: 'Item 1',
150+
items: [
151+
{ text: 'Item 1.1', items: [] },
152+
{ text: 'Item 1.2', items: [] }
153+
]
154+
},
155+
{
156+
text: 'Item 2',
157+
items: [
158+
{ text: 'Item 2.1', items: [] },
159+
{ text: 'Item 2.2', items: [] }
160+
]
161+
}
162+
];
163+
164+
$rootScope.sortableOptions = {};
165+
$rootScope.innerSortableOptions = {
166+
connectWith: '.nested-sortable'
167+
};
168+
});
169+
170+
host.append(elementTree);
171+
172+
li1 = elementTree.find('.innerList:last');
173+
li2 = elementTree.find('.innerList:first');
174+
simulateElementDrag(li1, li2, { place: 'above', extradx: -10, extrady: -6 });
175+
expect($rootScope.items.map(function(x){ return x.text; }))
176+
.toEqual(['Item 2', 'Item 1']);
177+
expect($rootScope.items.map(function(x){ return x.text; }))
178+
.toEqual(listInnerContent(elementTree, '.lvl1ItemContent'));
179+
180+
$(elementTree).remove();
181+
});
182+
});
183+
131184
});
132185

133186
});

0 commit comments

Comments
 (0)