Sha256: f142b360d6f085439131d3cb5e50fd0530d57bbc14f5ce1059932500d46f8d0a

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

window.Konacha = {
  reset: function() {
    document.body = document.createElement('body');
    document.body.id = 'konacha';
  }
};

window.Mocha = Object.create(parent.Mocha);
window.mocha = Object.create(parent.mocha);

// In order to isolate top-level before/beforeEach hooks,
// the specs in each iframe are wrapped in an anonymous suite.
mocha.suite = Mocha.Suite.create(mocha.suite);
mocha.suite.path = document.documentElement.getAttribute("data-path");

// Override mocha.ui so that the pre-require event is emitted
// with the iframe's `window` reference, rather than the parent's.
mocha.ui = function (name) {
  this._ui = Mocha.interfaces[name];
  if (!this._ui) throw new Error('invalid interface "' + name + '"');
  this._ui = this._ui(this.suite);
  this.suite.emit('pre-require', window, null, this);
  return this;
};

mocha.ui('bdd');

mocha.suite.beforeAll(function () {
  var contexts = parent.document.getElementsByClassName("test-context");
  for (var i = 0; i < contexts.length; ++i) {
    if (contexts[i].contentWindow == window) {
      contexts[i].style.display = "block";
    } else {
      contexts[i].style.display = null;
    }
  }
});

mocha.suite.beforeEach(function () {
  Konacha.reset();
});

var expect = chai.expect,
    should = chai.should(),
    assert = chai.assert;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
konacha-2.6.0 app/assets/javascripts/konacha/iframe.js
konacha-2.3.0 app/assets/javascripts/konacha/iframe.js
konacha-2.2.0 app/assets/javascripts/konacha/iframe.js
konacha-2.1.0 app/assets/javascripts/konacha/iframe.js
konacha-2.0.0 app/assets/javascripts/konacha/iframe.js