From: Nicolas Coden Date: Sat, 11 Aug 2018 20:40:40 +0000 (+0200) Subject: test: prevent cache in iframe in MediaQuery unit tests X-Git-Tag: v6.6.0~1^2~2^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95ba4009b69b993908a96bcfa7960e9e68321ffb;p=thirdparty%2Ffoundation%2Ffoundation-sites.git test: prevent cache in iframe in MediaQuery unit tests --- diff --git a/test/javascript/util/mediaQuery.js b/test/javascript/util/mediaQuery.js index e44eab96c..883bb8f30 100644 --- a/test/javascript/util/mediaQuery.js +++ b/test/javascript/util/mediaQuery.js @@ -19,6 +19,8 @@ describe('MediaQuery utils', function () { `; beforeEach(function (done) { + // Versionize scripts to prevent browser caching + const randomHash = (Math.random() * Math.pow(2, 54)).toString(36); // Create an Iframe so we can resize it to test mediaQueries const iframe = document.createElement("iframe"); @@ -33,10 +35,10 @@ describe('MediaQuery utils', function () { // Inject jQuery and Foundation injectScriptIn(_document.body, { - src: 'http://127.0.0.1:3042/node_modules/jquery/dist/jquery.js', + src: `http://127.0.0.1:3042/node_modules/jquery/dist/jquery.js?v=${randomHash}`, }); injectScriptIn(_document.body, { - src: 'http://127.0.0.1:3042/_build/assets/js/foundation.js', + src: `http://127.0.0.1:3042/_build/assets/js/foundation.js?v=${randomHash}`, onload: () => { plugin = _window.Foundation.MediaQuery; plugin._init(); @@ -47,7 +49,7 @@ describe('MediaQuery utils', function () { }); afterEach(function() { - // $iframe.remove(); + $iframe.remove(); });