diff options
Diffstat (limited to 'tests/unit/draggable')
-rw-r--r-- | tests/unit/draggable/core.js | 51 | ||||
-rw-r--r-- | tests/unit/draggable/helper.js | 3 | ||||
-rw-r--r-- | tests/unit/draggable/options.js | 38 |
3 files changed, 34 insertions, 58 deletions
diff --git a/tests/unit/draggable/core.js b/tests/unit/draggable/core.js index 46c856d4e..d7f786c93 100644 --- a/tests/unit/draggable/core.js +++ b/tests/unit/draggable/core.js @@ -38,8 +38,8 @@ QUnit.test( "element types", function( assert ) { } ); offsetAfter = el.offset(); - // Support: FF, Chrome, and IE9, - // there are some rounding errors in so we can't say equal, we have to settle for close enough + // Support: Firefox, Chrome + // There are some rounding errors, so we can't say equal, we have to settle for close enough assert.close( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + "> left" ); assert.close( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + "> top" ); el.draggable( "destroy" ); @@ -112,7 +112,6 @@ QUnit.test( "Stray mousemove after mousedown still drags", function( assert ) { // In IE8, when content is placed under the mouse (e.g. when draggable content is replaced // on mousedown), mousemove is triggered on those elements even though the mouse hasn't moved. - // Support: IE <9 element.on( "mousedown", function() { $( document ).simulate( "mousemove", { button: -1 } ); } ); @@ -341,11 +340,13 @@ QUnit.test( "blur behavior - off handle", function( assert ) { var element = $( "#draggable2" ).draggable( { handle: "span" } ), focusElement = $( "<div tabindex='1'></div>" ).appendTo( element ); - // Mock $.ui.safeBlur with a spy - var _safeBlur = $.ui.safeBlur; + // Mock $.ui.trigger with a spy + var _trigger = $.fn.trigger; var blurCalledCount = 0; - $.ui.safeBlur = function() { - blurCalledCount++; + $.fn.trigger = function( eventName ) { + if ( eventName === "blur" ) { + blurCalledCount++; + } }; testHelper.onFocus( focusElement, function() { @@ -357,8 +358,8 @@ QUnit.test( "blur behavior - off handle", function( assert ) { testHelper.move( element.find( "span" ), 1, 1 ); assert.strictEqual( blurCalledCount, 1, "draggable blurs when mousing down on handle" ); - // Restore safeBlur - $.ui.safeBlur = _safeBlur; + // Restore trigger + $.fn.trigger = _trigger; ready(); } ); @@ -394,27 +395,21 @@ QUnit.test( "ui-draggable-handle managed correctly in nested draggables", functi assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" ); } ); -// Support: IE 8 only -// IE 8 implements DOM Level 2 Events which only has events bubble up to the document. -// We skip this test since it would be impossible for it to pass in such an environment. -QUnit[ document.documentMode === 8 ? "skip" : "test" ]( - "does not stop propagation to window", - function( assert ) { - assert.expect( 1 ); - var element = $( "#draggable1" ).draggable(); +QUnit.test( "does not stop propagation to window", function( assert ) { + assert.expect( 1 ); + var element = $( "#draggable1" ).draggable(); - var handler = function() { - assert.ok( true, "mouseup propagates to window" ); - }; - $( window ).on( "mouseup", handler ); + var handler = function() { + assert.ok( true, "mouseup propagates to window" ); + }; + $( window ).on( "mouseup", handler ); - element.simulate( "drag", { - dx: 10, - dy: 10 - } ); + element.simulate( "drag", { + dx: 10, + dy: 10 + } ); - $( window ).off( "mouseup", handler ); - } -); + $( window ).off( "mouseup", handler ); +} ); } ); diff --git a/tests/unit/draggable/helper.js b/tests/unit/draggable/helper.js index 292b75bf0..2fd637a24 100644 --- a/tests/unit/draggable/helper.js +++ b/tests/unit/draggable/helper.js @@ -8,9 +8,6 @@ define( [ return $.extend( helper, { - // TODO: remove the unreliable offset hacks - unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, - testDragPosition: function( assert, el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js index 79aac27c2..f97696920 100644 --- a/tests/unit/draggable/options.js +++ b/tests/unit/draggable/options.js @@ -743,11 +743,11 @@ QUnit.test( "cursorAt", function( assert ) { assert.equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); assert.equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); - assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); + assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x, testName + " " + position + " left" ); + assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y, testName + " " + position + " top" ); } else { - assert.equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); - assert.equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); + assert.equal( event.clientX - ui.offset.left, testData.x, testName + " " + position + " left" ); + assert.equal( event.clientY - ui.offset.top, testData.y, testName + " " + position + " top" ); } } } ); @@ -785,11 +785,11 @@ QUnit.test( "cursorAt, switching after initialization", function( assert ) { assert.equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); assert.equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); - assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); + assert.equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x, testName + " " + position + " left" ); + assert.equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y, testName + " " + position + " top" ); } else { - assert.equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); - assert.equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); + assert.equal( event.clientX - ui.offset.left, testData.x, testName + " " + position + " left" ); + assert.equal( event.clientY - ui.offset.top, testData.y, testName + " " + position + " top" ); } } } ); @@ -1136,15 +1136,6 @@ QUnit.test( "scroll ignores containers that are overflow: hidden", function( ass dy: 1300 } ); - // IE8 natively scrolls when dragging an element inside a overflow:hidden - // container, so skip this test if native scroll occurs. - // Support: IE <9 - if ( scrollParent.scrollTop() > 0 ) { - assert.ok( true, "overflow:hidden container natively scrolls" ); - assert.ok( true, "overflow:hidden container natively scrolls" ); - return; - } - element.css( { top: 0, left: 0 } ).draggable( "option", "scroll", true ); element.simulate( "drag", { @@ -1458,7 +1449,7 @@ QUnit.test( "zIndex, default, switching after initialization", function( assert } ); QUnit.test( "iframeFix", function( assert ) { - assert.expect( 6 ); + assert.expect( 5 ); var element = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: true } ), element2 = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: ".iframe" } ), @@ -1474,8 +1465,7 @@ QUnit.test( "iframeFix", function( assert ) { } ); element.one( "drag", function() { - var divOffset, iframeOffset, - div = $( this ).children().not( "iframe" ); + var div = $( this ).children().not( "iframe" ); // https://bugs.jqueryui.com/ticket/9671 // iframeFix doesn't handle iframes that move @@ -1483,13 +1473,7 @@ QUnit.test( "iframeFix", function( assert ) { assert.equal( div.outerWidth(), iframe.outerWidth(), "blocking div is wide enough" ); assert.equal( div.outerHeight(), iframe.outerHeight(), "blocking div is tall enough" ); - divOffset = div.offset(); - iframeOffset = iframe.offset(); - - // Support: Edge <79 only - // In Edge Legacy these values differ a little. - assert.ok( Math.abs( divOffset.top - iframeOffset.top ) < 0.25, "Check top within 0.25 of expected" ); - assert.ok( Math.abs( divOffset.left - iframeOffset.left ) < 0.25, "Check left within 0.25 of expected" ); + assert.deepEqual( div.offset(), iframe.offset(), "blocking div is tall enough" ); } ); element.simulate( "drag", { |