diff options
author | Andrei Picus <office.nightcrawler@gmail.com> | 2013-10-29 15:48:51 +0200 |
---|---|---|
committer | Mike Sherov <mike.sherov@gmail.com> | 2013-10-29 13:58:15 -0400 |
commit | ffab89e9bee97cf7cc74249b6e4ce9dd798013c9 (patch) | |
tree | a28c9160b5a78b53d84b31730141035d44b022c2 /tests/unit/droppable | |
parent | a3715a7c919d242e3ffcdddc2f1db61133d9f560 (diff) | |
download | jquery-ui-ffab89e9bee97cf7cc74249b6e4ce9dd798013c9.tar.gz jquery-ui-ffab89e9bee97cf7cc74249b6e4ce9dd798013c9.zip |
Droppable: update ddmanager when scope changes through setOption. Fixed #9287 - droppable: Scope option cannot be changed after initialization.
Diffstat (limited to 'tests/unit/droppable')
-rw-r--r-- | tests/unit/droppable/droppable_options.js | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js index c2ecdcfda..1d8f95da9 100644 --- a/tests/unit/droppable/droppable_options.js +++ b/tests/unit/droppable/droppable_options.js @@ -35,6 +35,48 @@ test("{ addClasses: false }", function() { ok(!el.is(".ui-droppable"), "'ui-droppable' class not added"); el.droppable("destroy"); }); + +test( "scope", function() { + expect( 4 ); + var droppableOffset, draggableOffset, oldDraggableOffset, dx, dy, + draggable1 = $("<div></div>").appendTo( "#qunit-fixture" ).draggable({ revert: "invalid" }), + draggable2 = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(), + droppable = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(), + newScope = "test"; + + draggable1.draggable( "option", "scope", newScope ); + droppable.droppable( "option", "scope", newScope ); + + // Test that droppable accepts draggable with new scope. + droppableOffset = droppable.offset(); + draggableOffset = draggable1.offset(); + dx = droppableOffset.left - draggableOffset.left; + dy = droppableOffset.top - draggableOffset.top; + + draggable1.simulate( "drag", { + dx: dx, + dy: dy + }); + + draggableOffset = draggable1.offset(); + equal( draggableOffset.left, droppableOffset.left ); + equal( draggableOffset.top, droppableOffset.top ); + + // Test that droppable doesn't accept draggable with old scope. + draggableOffset = draggable2.offset(); + dx = droppableOffset.left - draggableOffset.left; + dy = droppableOffset.top - draggableOffset.top; + oldDraggableOffset = draggableOffset; + + draggable2.simulate( "drag", { + dx: dx, + dy: dy + }); + + draggableOffset = draggable2.offset(); + equal( draggableOffset.left, oldDraggableOffset.left ); + equal( draggableOffset.top, oldDraggableOffset.top ); +}); /* test("greedy", function() { ok(false, 'missing test - untested code is broken code'); @@ -44,10 +86,6 @@ test("hoverClass", function() { ok(false, 'missing test - untested code is broken code'); }); -test("scope", function() { - ok(false, 'missing test - untested code is broken code'); -}); - test("tolerance, fit", function() { ok(false, 'missing test - untested code is broken code'); }); |