Sha256: e071b0240658f19071e1b1ee5dcbec44ec8941a5808d826ccf12164bf1080c98

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

(function (root) {
  "use strict"
  var loadedScripts = 0,
      totalScripts,
      merge,
      loadScript,
      runJasmine,
      manifestScript;

  merge = function (arrays) {
    var resultingArray = [],
        workingArray,
        a, b, x, y;

    for (a = 0, b = arrays.length; a < b; a++) {
      workingArray = arrays[a];
      for (x = 0, y = workingArray.length; x < y; x++) {
        resultingArray.push(workingArray[x]);
      }
    }
    return resultingArray;
  };
  loadScript = function (src, nextIdx) {
    var script = document.createElement('script'),
        nextScript; 

    script.type = 'text/javascript';
    script.src = src;

    document.getElementsByTagName('head')[0].appendChild(script);
    if (nextIdx === undefined) { return script; }
    script.onload = function () {
      if (nextIdx < totalScripts.length) {
        loadScript(totalScripts[nextIdx], nextIdx + 1);
      } else {
        runJasmine();
      }
    };
    return script;
  };
  runJasmine = function () {
    var console_reporter = new jasmine.ConsoleReporter()
    jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
    jasmine.getEnv().addReporter(console_reporter);
    jasmine.getEnv().execute();
  };
  manifestScript = loadScript('../manifest.js');

  manifestScript.onload = function () {
    var idx = 0;
  
    totalScripts = merge([manifest.support, manifest.test]);
    loadScript(totalScripts[idx], idx + 1);
  };
}).call(this);

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
govuk_frontend_toolkit-3.0.1 app/assets/spec/support/load.js
govuk_frontend_toolkit-3.0.0 app/assets/spec/support/load.js
govuk_frontend_toolkit-2.0.1 app/assets/spec/support/load.js
govuk_frontend_toolkit-2.0.0 app/assets/spec/support/load.js
govuk_frontend_toolkit-1.7.0 app/assets/spec/support/load.js
govuk_frontend_toolkit-1.6.2 app/assets/spec/support/load.js
govuk_frontend_toolkit-1.6.1 app/assets/spec/support/load.js
govuk_frontend_toolkit-1.6.0 app/assets/spec/support/load.js
govuk_frontend_toolkit-1.5.0 app/assets/spec/support/load.js