Skip to content

Commit 8b1b34c

Browse files
committed
Sortable Tests: Add tests to support #9041 and #8792
1 parent 07ce771 commit 8b1b34c

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

tests/unit/sortable/sortable_events.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,34 @@ test("receive", function() {
231231
test("remove", function() {
232232
ok(false, "missing test - untested code is broken code.");
233233
});
234+
*/
234235

235-
test("over", function() {
236-
ok(false, "missing test - untested code is broken code.");
236+
test( "over", function() {
237+
expect( 8 );
238+
239+
var hash,
240+
overCount = 0;
241+
242+
$( "#sortable" ).sortable({
243+
over: function( e, ui ) {
244+
hash = ui;
245+
overCount++;
246+
}
247+
}).find( "li:eq(0)" ).simulate( "drag", {
248+
dy: 20
249+
});
250+
251+
ok( hash, "stop event triggered" );
252+
ok( hash.helper, "UI should not include: helper" );
253+
ok( hash.placeholder, "UI hash includes: placeholder" );
254+
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
255+
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
256+
ok( hash.item, "UI hash includes: item" );
257+
ok( hash.sender, "UI hash does not include: sender" );
258+
equal( overCount, 1, "over fires only once" );
237259
});
238260

261+
/*
239262
test("out", function() {
240263
ok(false, "missing test - untested code is broken code.");
241264
});

tests/unit/sortable/sortable_options.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,44 @@ test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
3737
test("{ cancel: Selector }", function() {
3838
ok(false, "missing test - untested code is broken code.");
3939
});
40+
*/
41+
42+
test( "#8792: issues with floated items in connected lists", function() {
43+
expect( 2 );
44+
45+
var element,
46+
changeCount = 0;
47+
48+
$( "#qunit-fixture" )
49+
.html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" )
50+
.find( "ul" ).css({ "float": "left", width: "100px" }).end()
51+
.find( "li" ).css({ "float": "left", width: "50px", height: "50px" });
52+
53+
$( "#qunit-fixture .c" ).sortable({
54+
connectWith: "#qunit-fixture .c",
55+
change: function() {
56+
changeCount++;
57+
}
58+
});
59+
60+
element = $( "#qunit-fixture li:eq(0)" );
4061

62+
element.simulate( "drag", {
63+
dx: 51,
64+
moves: 15
65+
});
66+
67+
equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
68+
69+
element.simulate( "drag", {
70+
dx: 50,
71+
moves: 15
72+
});
73+
74+
equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
75+
});
76+
77+
/*
4178
test("{ connectWith: false }, default", function() {
4279
ok(false, "missing test - untested code is broken code.");
4380
});

0 commit comments

Comments
 (0)