From: Daniel Ruf Date: Mon, 16 Apr 2018 07:41:36 +0000 (+0200) Subject: tests: prevent race condition in _reflow test X-Git-Tag: v6.6.0~3^2~222^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1eb8b1fdf;p=thirdparty%2Ffoundation%2Ffoundation-sites.git tests: prevent race condition in _reflow test --- diff --git a/test/javascript/components/interchange.js b/test/javascript/components/interchange.js index f38a57e02..6734b3576 100755 --- a/test/javascript/components/interchange.js +++ b/test/javascript/components/interchange.js @@ -170,12 +170,10 @@ describe('Interchange', function() { it('calls reflow on viewport size change once', function(done) { $html = $(generateTemplate('image')).appendTo('body'); plugin = new Foundation.Interchange($html, {}); - Foundation.IHearYou(); - let spy = sinon.spy(plugin, '_reflow'); - setTimeout(function() { - $(window).trigger('resize'); + Foundation.IHearYou(); }, 1); + let spy = sinon.spy(plugin, '_reflow'); setTimeout(function() { $(window).trigger('resize'); @@ -185,6 +183,10 @@ describe('Interchange', function() { $(window).trigger('resize'); }, 10); + setTimeout(function() { + $(window).trigger('resize'); + }, 20); + setTimeout(function() { // Wait for third trigger... sinon.assert.calledOnce(spy); done();