Skip to content

Commit 579bedd

Browse files
authored
Tests: Solve a frequent race condition in tests in Chrome/Safari
Closes jquerygh-1916
1 parent d37ebc6 commit 579bedd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/unit/sortable/options.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,23 @@ test("{ placeholder: false }, default", function() {
372372
QUnit.test( "{ placeholder: false } img", function( assert ) {
373373
assert.expect( 3 );
374374

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

383-
element.find( "img" ).eq( 0 ).simulate( "drag", {
384-
dy: 1
385-
} );
384+
// Give browsers some time to load the image if cache is disabled.
385+
// This resolves a frequent issue in Chrome/Safari.
386+
setTimeout( function() {
387+
element.find( "img" ).eq( 0 ).simulate( "drag", {
388+
dy: 1
389+
} );
390+
done();
391+
}, 500 );
386392
} );
387393

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

0 commit comments

Comments
 (0)