Skip to content

Commit 4a1afbd

Browse files
committed
Restructure test to avoid setTimeout
1 parent dd585b2 commit 4a1afbd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: test/jasmine/tests/layout_images_test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,17 @@ describe('Layout images', function() {
306306
return element;
307307
});
308308

309-
Plotly.relayout(gd, 'images[0].source', dataUriImage).then(function() {
310-
setTimeout(function() {
311-
expect(newCanvasElement).toBeUndefined();
312-
Plotly.relayout(gd, 'images[0].source', pythonLogo).then(function() {
313-
expect(newCanvasElement).eventually.toBeDefined();
314-
expect(newCanvasElement.toDataURL).toHaveBeenCalledTimes(1);
315-
});
316-
317-
done();
318-
}, 500);
319-
});
309+
Plotly.relayout(gd, 'images[0].source', dataUriImage)
310+
.then(function() {
311+
expect(newCanvasElement).toBeUndefined();
312+
})
313+
.then(function() { return Plotly.relayout(gd, 'images[0].source', jsLogo); })
314+
.then(function() {
315+
expect(newCanvasElement).toBeDefined();
316+
expect(newCanvasElement.toDataURL).toHaveBeenCalledTimes(1);
317+
})
318+
.catch(failTest)
319+
.then(done);
320320
});
321321

322322
it('should update the image if changed', function(done) {

0 commit comments

Comments
 (0)