Skip to content

Tests: Make some number comparisons less strict #1947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/unit/draggable/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ QUnit.test( "zIndex, default, switching after initialization", function( assert
} );

QUnit.test( "iframeFix", function( assert ) {
assert.expect( 5 );
assert.expect( 6 );

var element = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: true } ),
element2 = $( "<div>" ).appendTo( "#qunit-fixture" ).draggable( { iframeFix: ".iframe" } ),
Expand All @@ -1485,14 +1485,22 @@ QUnit.test( "iframeFix", function( assert ) {
} );

element.one( "drag", function() {
var div = $( this ).children().not( "iframe" );
var divOffset, iframeOffset,
div = $( this ).children().not( "iframe" );

// http://bugs.jqueryui.com/ticket/9671
// iframeFix doesn't handle iframes that move
assert.equal( div.length, 1, "blocking div added as sibling" );
assert.equal( div.outerWidth(), iframe.outerWidth(), "blocking div is wide enough" );
assert.equal( div.outerHeight(), iframe.outerHeight(), "blocking div is tall enough" );
assert.deepEqual( div.offset(), iframe.offset(), "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" );
} );

element.simulate( "drag", {
Expand Down
16 changes: 13 additions & 3 deletions tests/unit/sortable/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,24 @@ QUnit.test( "{ forcePlaceholderSize: true } table rows", function( assert ) {
assert.expect( 2 );

// Table should have the placeholder's height set the same as the row we're dragging
var element = $( "#sortable-table2 tbody" );
var element = $( "#sortable-table2 tbody" ),
jqMinor = $.fn.jquery.substring( 0, 4 );

element.sortable( {
placeholder: "test",
forcePlaceholderSize: true,
start: function( event, ui ) {
assert.equal( ui.placeholder.height(), ui.item.height(),
"placeholder is same height as item" );

// Support: IE 11+, Edge <79 only
// In IE & Edge Legacy these values may differ a little
// when jQuery >=3.0 <3.2 is used.
if ( jqMinor === "3.0." || jqMinor === "3.1." ) {
assert.ok( Math.abs( ui.placeholder.height() - ui.item.height() ) < 0.25,
"placeholder height is within 0.25 px of item's" );
} else {
assert.equal( ui.placeholder.height(), ui.item.height(),
"placeholder is same height as item" );
}
}
} );

Expand Down