Tests: Solve a frequent race condition in tests in Chrome/Safari

Closes gh-1916
This commit is contained in:
Michał Gołębiowski-Owczarek 2020-05-16 08:28:26 +02:00 committed by GitHub
parent d37ebc624d
commit 579bedd7d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -372,7 +372,8 @@ 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" );
@ -380,9 +381,14 @@ QUnit.test( "{ placeholder: false } img", function( assert ) {
}
} );
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 ) {