aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/draggable
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2015-03-31 16:52:28 -0400
committerScott González <scott.gonzalez@gmail.com>2015-04-09 09:24:45 -0400
commit2e1c72fb59b3e41da15ebcd83640dbdf13a90d27 (patch)
tree0a294a24d275202594cd4953843c73f5105677cc /tests/unit/draggable
parent7c896ddb8563e1f4fc655904614cf72d010e2ecb (diff)
downloadjquery-ui-2e1c72fb59b3e41da15ebcd83640dbdf13a90d27.tar.gz
jquery-ui-2e1c72fb59b3e41da15ebcd83640dbdf13a90d27.zip
Tests: Convert closeEnough() to a proper QUnit assertion
Should eventually replace with qunit-assert-close. Ref #10119 Ref gh-1528
Diffstat (limited to 'tests/unit/draggable')
-rw-r--r--tests/unit/draggable/draggable_core.js6
-rw-r--r--tests/unit/draggable/draggable_options.js28
2 files changed, 17 insertions, 17 deletions
diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js
index bce3f4e23..b3a7e7ef3 100644
--- a/tests/unit/draggable/draggable_core.js
+++ b/tests/unit/draggable/draggable_core.js
@@ -6,7 +6,7 @@
module( "draggable: core" );
-test( "element types", function() {
+test( "element types", function( assert ) {
var typeNames = (
"p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" +
",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" +
@@ -35,8 +35,8 @@ test( "element types", function() {
// Support: FF, Chrome, and IE9,
// there are some rounding errors in so we can't say equal, we have to settle for close enough
- closeEnough( offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
- closeEnough( offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">" );
+ 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");
el.remove();
});
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index d8bbedc91..0d4957136 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -519,7 +519,7 @@ test( "{ containment: 'parent' }, absolute", function() {
deepEqual( offsetAfter, expected, "compare offset to parent" );
});
-test( "containment, account for border", function() {
+test( "containment, account for border", function( assert ) {
expect( 2 );
var el = $( "#draggable1" ).appendTo( "#scrollParent" ),
@@ -544,9 +544,9 @@ test( "containment, account for border", function() {
dy: 100
});
- closeEnough( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1,
+ assert.close( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1,
"The draggable should be on top of its parent's bottom border" );
- closeEnough( el.offset().left, parentRight - parentBorderRight - el.width(), 1,
+ assert.close( el.offset().left, parentRight - parentBorderRight - el.width(), 1,
"The draggable should be to the right of its parent's right border" );
});
@@ -1137,7 +1137,7 @@ test( "scroll ignores containers that are overflow: hidden", function() {
equal( scrollParent.scrollLeft(), 0, "container doesn't scroll horizontally" );
});
-test( "#6817: auto scroll goes double distance when dragging", function() {
+test( "#6817: auto scroll goes double distance when dragging", function( assert ) {
expect( 2 );
TestHelpers.draggable.restoreScroll( document );
@@ -1149,8 +1149,8 @@ test( "#6817: auto scroll goes double distance when dragging", function() {
scroll: true,
stop: function( e, ui ) {
equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
- // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
- closeEnough( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
+ // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
+ assert.close( ui.offset.top - offsetBefore.top, distance, 1, "offset of item only moves expected distance after scroll" );
}
}),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
@@ -1174,7 +1174,7 @@ test( "#6817: auto scroll goes double distance when dragging", function() {
TestHelpers.draggable.restoreScroll( document );
});
-test( "snap, snapMode, and snapTolerance", function() {
+test( "snap, snapMode, and snapTolerance", function( assert ) {
expect( 10 );
var newX, newY,
@@ -1206,9 +1206,9 @@ test( "snap, snapMode, and snapTolerance", function() {
moves: 1
});
- // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
- closeEnough( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" );
- closeEnough( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" );
+ // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
+ assert.close( element.offset().left, newX, 1, "doesn't snap outside the snapTolerance" );
+ assert.close( element.offset().top, newY, 1, "doesn't snap outside the snapTolerance" );
newX += 3;
@@ -1301,7 +1301,7 @@ test( "snap, snapMode, and snapTolerance", function() {
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" );
});
-test( "#8459: element can snap to an element that was removed during drag", function() {
+test( "#8459: element can snap to an element that was removed during drag", function( assert ) {
expect( 2 );
var newX, newY,
@@ -1337,9 +1337,9 @@ test( "#8459: element can snap to an element that was removed during drag", func
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
- // TODO: fix IE8 testswarm IFRAME positioning bug so closeEnough can be turned back to equal
- closeEnough( element.offset().left, newX, 1, "doesn't snap to a removed element" );
- closeEnough( element.offset().top, newY, 1, "doesn't snap to a removed element" );
+ // TODO: fix IE8 testswarm IFRAME positioning bug so assert.close can be turned back to equal
+ assert.close( element.offset().left, newX, 1, "doesn't snap to a removed element" );
+ assert.close( element.offset().top, newY, 1, "doesn't snap to a removed element" );
}
});