Skip to content

Commit

Permalink
Add spec_helper.js to test/templates
Browse files Browse the repository at this point in the history
  • Loading branch information
sh19910711 committed Jun 21, 2015
1 parent b354089 commit a05f96f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/templates/html/spec_runner.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="/templates/console.js"></script>

<!-- find and load test cases -->
<script src="/spec/spec_helper.js"></script>
<% Pathname.glob(TEST_ROOT.join "spec/**/*_spec.js") do |spec| %>
<script src="/<%= spec.relative_path_from TEST_ROOT %>"></script>
<% end %>
Expand Down
2 changes: 0 additions & 2 deletions test/templates/spec/dom_helpers_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var assert = chai.assert;

describe("DOM helpers", function() {
describe("hasClass()", function() {
context("create a <div>", function() {
Expand Down
25 changes: 25 additions & 0 deletions test/templates/spec/spec_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function() {
var SpecHelper = {
triggerEvent: function(el, eventName) {
var event = document.createEvent("MouseEvents");
event.initEvent(eventName, true, true); // type, bubbles, cancelable
el.dispatchEvent(event);
},
randomString: function() {
Math.random().toString(36).substring(2);
},
prepareStageElement: function() {
before(function() {
this.stageElement = document.createElement("div");
this.stageElement.style.display = "none";
document.body.appendChild(this.stageElement);
});
afterEach(function() {
this.stageElement.innerHTML = "";
});
}
};

window.SpecHelper = SpecHelper;
window.assert = chai.assert;
})();

0 comments on commit a05f96f

Please sign in to comment.