]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11179 from DanielRuf/tests/increase-timeouts-viewport-reflow-test...
authorDaniel Ruf <daniel.ruf@ueberbit.de>
Sat, 16 Jun 2018 08:08:12 +0000 (10:08 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Sat, 16 Jun 2018 20:58:48 +0000 (22:58 +0200)
1eb8b1fdf tests: prevent race condition in _reflow test

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
test/javascript/components/interchange.js

index f38a57e024e1d1355d01b10008664b8c761ff0ea..6734b35762bfa18a4d3733a0efaaf088e288985b 100755 (executable)
@@ -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();