UNPKG

hem

Version:

stitches CommonJS, and ties up other lose ends of web-app development.

114 lines (87 loc) 2.92 kB
<!DOCTYPE html> <html> <head> <meta charset="utf8" /> <title>Hem Test Runner</title> </head> <body> <script type="text/javascript"> (function() { function startTests() { // create jasmine environment var jasmineEnv = jasmine.getEnv(); jasmineEnv.updateInterval = 250; /** Create the `HTMLReporter`, which Jasmine calls to provide results of each spec and each suite. The Reporter is responsible for presenting results to the user. */ var htmlReporter = new jasmine.HtmlReporter(); jasmineEnv.addReporter(htmlReporter); /** Delegate filtering of specs to the reporter. Allows for clicking on single suites or specs in the results to only run a subset of the suite. */ jasmineEnv.specFilter = function(spec) { return htmlReporter.specFilter(spec); }; jasmineEnv.execute(); } window.onload = function() { var http = (location.protocol === "http:") var urlsToLoad = [] var filesToLoad = [] // files to load urlsToLoad.push("jasmine/1.jasmine.js") filesToLoad.push("jasmine/1.jasmine.js") urlsToLoad.push("jasmine/2.jasmine-html.js") filesToLoad.push("jasmine/2.jasmine-html.js") urlsToLoad.push("jasmine/jasmine.css") filesToLoad.push("jasmine/jasmine.css") urlsToLoad.push("../application.js") filesToLoad.push("../../public/application.js") urlsToLoad.push("specs.js") filesToLoad.push("specs.js") // determine if using http to load files var files = http ? urlsToLoad : filesToLoad // function to create elements to load css/js var loadCssOrScript = function(position) { // start tests if everything loaded if (position >= files.length) { startTests(); return; } // create document elements var head = document.getElementsByTagName("HEAD").item(0); var child; var source = files[position]; // handle js if (source.indexOf(".js") > -1) { child = document.createElement("script"); child.type = "text/javascript"; child.src = source; // handle css } else { // skip css files for phantomjs if (navigator.userAgent.indexOf("PhantomJS") > -1) { loadCssOrScript(++position); return } child = document.createElement("link"); child.setAttribute("rel", "stylesheet") child.type = "text/css"; child.href = source; } // handle next call child.onload = function() { loadCssOrScript(++position); } // add child to document to load head.appendChild(child); } // dynamically load application and specs javascript files loadCssOrScript(0) }; })(); </script> </body> </html>