]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
test: prevent cache in iframe in MediaQuery unit tests
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 11 Aug 2018 20:40:40 +0000 (22:40 +0200)
committerDaniel Ruf <mac1@daniel-ruf.de>
Sun, 17 Nov 2019 15:48:09 +0000 (16:48 +0100)
test/javascript/util/mediaQuery.js

index e44eab96c727542f8a99537f4aca61a178956773..883bb8f30a2c004454cb6bdf0abef2f938b7c18f 100644 (file)
@@ -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();
   });