Skip to content

Commit

Permalink
Tests: Solve a frequent race condition in tests in Chrome/Safari
Browse files Browse the repository at this point in the history
Closes gh-1916
  • Loading branch information
mgol committed May 16, 2020
1 parent d37ebc6 commit 579bedd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/unit/sortable/options.js
Expand Up @@ -372,17 +372,23 @@ test("{ placeholder: false }, default", function() {
QUnit.test( "{ placeholder: false } img", function( assert ) {
assert.expect( 3 );

var element = $( "#sortable-images" ).sortable( {
var done = assert.async(),
element = $( "#sortable-images" ).sortable( {
start: function( event, ui ) {
assert.ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" );
assert.equal( ui.placeholder.height(), 32, "placeholder has correct height" );
assert.equal( ui.placeholder.width(), 32, "placeholder has correct width" );
}
} );

element.find( "img" ).eq( 0 ).simulate( "drag", {
dy: 1
} );
// Give browsers some time to load the image if cache is disabled.
// This resolves a frequent issue in Chrome/Safari.
setTimeout( function() {
element.find( "img" ).eq( 0 ).simulate( "drag", {
dy: 1
} );
done();
}, 500 );
} );

QUnit.test( "{ placeholder: String }", function( assert ) {
Expand Down

0 comments on commit 579bedd

Please sign in to comment.