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

Commit 1ed63cd

Browse files
committed
test(sortable.e2e.multi.spec): make connected lists floated
1 parent 492bfa1 commit 1ed63cd

File tree

5 files changed

+77
-108
lines changed

5 files changed

+77
-108
lines changed

test/karma.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ module.exports = function(config) {
3030
'src/sortable.js',
3131
'test/sortable.test-helper.js',
3232
'test/sortable.test-directives.js',
33-
'test/*.spec.js'
33+
'test/*.spec.js',
34+
'test/sortable.tests.css'
3435
]),
3536

3637

test/sortable.e2e.multi.spec.js

Lines changed: 25 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,19 @@ describe('uiSortable', function() {
4040
$rootScope.opts = { connectWith: '.cross-sortable' };
4141
});
4242

43-
host.append(elementTop).append(elementBottom);
43+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
4444

4545
var li1 = elementTop.find(':eq(0)');
4646
var li2 = elementBottom.find(':eq(0)');
4747
simulateElementDrag(li1, li2, 'below');
48-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
49-
// li1.simulate('drag', { dy: dy });
5048
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
5149
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
5250
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
5351
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
5452

5553
li1 = elementBottom.find(':eq(1)');
5654
li2 = elementTop.find(':eq(1)');
57-
simulateElementDrag(li1, li2, 'above');
58-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
59-
// li1.simulate('drag', { dy: dy });
55+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
6056
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
6157
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
6258
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -78,7 +74,7 @@ describe('uiSortable', function() {
7874
$rootScope.opts = { connectWith: '.cross-sortable' };
7975
});
8076

81-
host.append(elementTop).append(elementBottom);
77+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
8278

8379
function parseFalsyValue (value) {
8480
if (value === '0') {
@@ -90,18 +86,14 @@ describe('uiSortable', function() {
9086
var li1 = elementTop.find(':eq(0)');
9187
var li2 = elementBottom.find(':eq(0)');
9288
simulateElementDrag(li1, li2, 'below');
93-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
94-
// li1.simulate('drag', { dy: dy });
9589
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
9690
expect($rootScope.itemsBottom).toEqual(['Bottom One', 0, 'Bottom Two', 'Bottom Three']);
9791
expect($rootScope.itemsTop).toEqual(listContent(elementTop).map(parseFalsyValue));
9892
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom).map(parseFalsyValue));
9993

10094
li1 = elementBottom.find(':eq(1)');
10195
li2 = elementTop.find(':eq(1)');
102-
simulateElementDrag(li1, li2, 'above');
103-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
104-
// li1.simulate('drag', { dy: dy });
96+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
10597
expect($rootScope.itemsTop).toEqual(['Top Two', 0, 'Top Three']);
10698
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
10799
expect($rootScope.itemsTop).toEqual(listContent(elementTop).map(parseFalsyValue));
@@ -126,23 +118,19 @@ describe('uiSortable', function() {
126118
};
127119
});
128120

129-
host.append(elementTop).append(elementBottom);
121+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
130122

131123
var li1 = elementTop.find(':eq(0)');
132124
var li2 = elementBottom.find(':eq(0)');
133125
simulateElementDrag(li1, li2, 'below');
134-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
135-
// li1.simulate('drag', { dy: dy });
136126
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
137127
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
138128
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
139129
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
140130

141131
li1 = elementBottom.find(':eq(1)');
142132
li2 = elementTop.find(':eq(1)');
143-
simulateElementDrag(li1, li2, 'above');
144-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
145-
// li1.simulate('drag', { dy: dy });
133+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
146134
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
147135
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
148136
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -167,23 +155,19 @@ describe('uiSortable', function() {
167155
};
168156
});
169157

170-
host.append(elementTop).append(elementBottom);
158+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
171159

172160
var li1 = elementTop.find(':eq(0)');
173161
var li2 = elementBottom.find(':eq(0)');
174162
simulateElementDrag(li1, li2, 'below');
175-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
176-
// li1.simulate('drag', { dy: dy });
177163
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
178164
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
179165
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
180166
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
181167

182168
li1 = elementBottom.find(':eq(1)');
183169
li2 = elementTop.find(':eq(1)');
184-
simulateElementDrag(li1, li2, 'above');
185-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
186-
// li1.simulate('drag', { dy: dy });
170+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
187171
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
188172
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
189173
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -208,23 +192,19 @@ describe('uiSortable', function() {
208192
};
209193
});
210194

211-
host.append(elementTop).append(elementBottom);
195+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
212196

213197
var li1 = elementTop.find(':eq(0)');
214198
var li2 = elementBottom.find(':eq(0)');
215199
simulateElementDrag(li1, li2, 'below');
216-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
217-
// li1.simulate('drag', { dy: dy });
218200
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
219201
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
220202
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
221203
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
222204

223205
li1 = elementBottom.find(':eq(1)');
224206
li2 = elementTop.find(':eq(1)');
225-
simulateElementDrag(li1, li2, 'above');
226-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
227-
// li1.simulate('drag', { dy: dy });
207+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
228208
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
229209
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
230210
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -250,23 +230,19 @@ describe('uiSortable', function() {
250230
};
251231
});
252232

253-
host.append(elementTop).append(elementBottom);
233+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
254234

255235
var li1 = elementTop.find(':eq(0)');
256236
var li2 = elementBottom.find(':eq(0)');
257237
simulateElementDrag(li1, li2, 'below');
258-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
259-
// li1.simulate('drag', { dy: dy });
260238
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
261239
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
262240
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
263241
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
264242

265243
li1 = elementBottom.find(':eq(1)');
266244
li2 = elementTop.find(':eq(1)');
267-
simulateElementDrag(li1, li2, 'above');
268-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
269-
// li1.simulate('drag', { dy: dy });
245+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
270246
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
271247
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
272248
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -293,23 +269,19 @@ describe('uiSortable', function() {
293269
};
294270
});
295271

296-
host.append(elementTop).append(elementBottom);
272+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
297273

298274
var li1 = elementTop.find(':eq(0)');
299275
var li2 = elementBottom.find(':eq(0)');
300276
simulateElementDrag(li1, li2, 'below');
301-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
302-
// li1.simulate('drag', { dy: dy });
303277
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
304278
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
305279
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
306280
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
307281

308282
li1 = elementBottom.find(':eq(1)');
309283
li2 = elementTop.find(':eq(1)');
310-
simulateElementDrag(li1, li2, 'above');
311-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
312-
// li1.simulate('drag', { dy: dy });
284+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
313285
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
314286
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
315287
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -337,23 +309,19 @@ describe('uiSortable', function() {
337309
};
338310
});
339311

340-
host.append(elementTop).append(elementBottom);
312+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
341313

342314
var li1 = elementTop.find(':eq(0)');
343315
var li2 = elementBottom.find(':eq(0)');
344316
simulateElementDrag(li1, li2, 'below');
345-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
346-
// li1.simulate('drag', { dy: dy });
347317
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
348318
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
349319
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
350320
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
351321

352322
li1 = elementBottom.find(':eq(1)');
353323
li2 = elementTop.find(':eq(1)');
354-
simulateElementDrag(li1, li2, 'above');
355-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
356-
// li1.simulate('drag', { dy: dy });
324+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
357325
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
358326
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
359327
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -380,23 +348,19 @@ describe('uiSortable', function() {
380348
};
381349
});
382350

383-
host.append(elementTop).append(elementBottom);
351+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
384352

385353
var li1 = elementTop.find(':eq(0)');
386354
var li2 = elementBottom.find(':eq(0)');
387355
simulateElementDrag(li1, li2, 'below');
388-
// var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
389-
// li1.simulate('drag', { dy: dy });
390356
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
391357
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
392358
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
393359
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
394360

395361
li1 = elementBottom.find(':eq(1)');
396362
li2 = elementTop.find(':eq(1)');
397-
simulateElementDrag(li1, li2, 'above');
398-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
399-
// li1.simulate('drag', { dy: dy });
363+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
400364
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
401365
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
402366
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -424,22 +388,19 @@ describe('uiSortable', function() {
424388
};
425389
});
426390

427-
host.append(elementTop).append(elementBottom);
391+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
428392

429393
var li1 = elementTop.find(':eq(0)');
430394
var li2 = elementBottom.find(':eq(0)');
431-
var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
432-
li1.simulate('drag', { dy: dy });
395+
simulateElementDrag(li1, li2, 'below');
433396
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
434397
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
435398
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
436399
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
437400

438401
li1 = elementBottom.find(':eq(1)');
439402
li2 = elementTop.find(':eq(1)');
440-
simulateElementDrag(li1, li2, 'above');
441-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
442-
// li1.simulate('drag', { dy: dy });
403+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
443404
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
444405
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
445406
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -470,22 +431,19 @@ describe('uiSortable', function() {
470431
};
471432
});
472433

473-
host.append(elementTop).append(elementBottom);
434+
host.append(elementTop).append(elementBottom).append('<div class="clear"></div>');
474435

475436
var li1 = elementTop.find(':eq(1)');
476437
var li2 = elementBottom.find(':eq(0)');
477-
var dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
478-
li1.simulate('drag', { dy: dy });
438+
simulateElementDrag(li1, li2, 'below');
479439
expect($rootScope.itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
480440
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
481441
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
482442
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
483443

484444
li1 = elementBottom.find(':eq(1)');
485445
li2 = elementTop.find(':eq(1)');
486-
simulateElementDrag(li1, li2, 'above');
487-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
488-
// li1.simulate('drag', { dy: dy });
446+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
489447
expect($rootScope.itemsTop).toEqual(['Top One', 'Top Two', 'Top Three']);
490448
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
491449
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
@@ -494,18 +452,14 @@ describe('uiSortable', function() {
494452
li1 = elementTop.find(':eq(0)');
495453
li2 = elementBottom.find(':eq(0)');
496454
simulateElementDrag(li1, li2, 'below');
497-
// dy = EXTRA_DY_PERCENTAGE * li1.outerHeight() + (li2.position().top - li1.position().top);
498-
// li1.simulate('drag', { dy: dy });
499455
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top Three']);
500456
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Top One', 'Bottom Two', 'Bottom Three']);
501457
expect($rootScope.itemsTop).toEqual(listContent(elementTop));
502458
expect($rootScope.itemsBottom).toEqual(listContent(elementBottom));
503459

504460
li1 = elementBottom.find(':eq(1)');
505461
li2 = elementTop.find(':eq(1)');
506-
simulateElementDrag(li1, li2, 'above');
507-
// dy = -EXTRA_DY_PERCENTAGE * li1.outerHeight() - (li1.position().top - li2.position().top);
508-
// li1.simulate('drag', { dy: dy });
462+
simulateElementDrag(li1, li2, { place: 'above', extradx: -20, extrady: -10 });
509463
expect($rootScope.itemsTop).toEqual(['Top Two', 'Top One', 'Top Three']);
510464
expect($rootScope.itemsBottom).toEqual(['Bottom One', 'Bottom Two', 'Bottom Three']);
511465
expect($rootScope.itemsTop).toEqual(listContent(elementTop));

0 commit comments

Comments
 (0)