]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
tests: prevent race condition in _reflow test 11179/head
authorDaniel Ruf <daniel.ruf@ueberbit.de>
Mon, 16 Apr 2018 07:41:36 +0000 (09:41 +0200)
committerDaniel Ruf <daniel@daniel-ruf.de>
Sun, 22 Apr 2018 21:09:50 +0000 (23:09 +0200)
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();