Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get rid of unnecessary self in ninjaTest

  • Loading branch information...
commit a2bef3c633f5e48512454240954415f5e3605011 1 parent 169a9ef
@andywenk authored
Showing with 51 additions and 51 deletions.
  1. +51 −51 lib/ninjaTest.js
View
102 lib/ninjaTest.js
@@ -1,108 +1,108 @@
-var ninjaTest = function () {
+var ninjaTest = (function () {
var self = this;
- self.queue = [];
- self.paused = false;
- self.results;
+ var queue = [];
+ var paused = false;
+ var results;
// public methods
- self.createStatusBar = function () {
- var statusBarTag = self.append(self.byId("results"), self.createEl("div"));
+ createStatusBar = function () {
+ var statusBarTag = append(byId("results"), createEl("div"));
statusBarTag.id = "status";
- self.append(statusBarTag, self.text('Status: '));
+ append(statusBarTag, text('Status: '));
};
- self.intro = function (intro) {
- var introTag = self.append(self.byId("results"), self.createEl("div"));
+ intro = function (intro) {
+ var introTag = append(byId("results"), createEl("div"));
introTag.id = "intro";
- self.append(introTag, self.text(intro));
+ append(introTag, text(intro));
};
- self.assert = function (value, description, group) {
- var result = self.createResult(value, description);
- self.append(results, result);
- self.groupNodeStatus(value, result);
- self.setStatusBarProgress(value, group);
+ assert = function (value, description, group) {
+ var result = createResult(value, description);
+ append(results, result);
+ groupNodeStatus(value, result);
+ setStatusBarProgress(value, group);
return result;
};
- self.test = function (name, fn) {
- self.queue.push(function () {
- self.results = self.byId("results");
- self.createGroup(name);
+ test = function (name, fn) {
+ queue.push(function () {
+ results = byId("results");
+ createGroup(name);
fn();
});
- self.runTest();
+ runTest();
};
// private methods
- self.createGroup = function (name) {
- var groupElement = self.assert(true, name, true);
- self.results = self.append(groupElement, self.createEl("div"));
- self.results.className = "group";
+ createGroup = function (name) {
+ var groupElement = assert(true, name, true);
+ results = append(groupElement, createEl("div"));
+ results.className = "group";
};
- self.createResult = function (value, description) {
- var resultTag = self.createEl("p");
- resultTag.className = self.result(value);
- self.append(resultTag, self.text(description));
+ createResult = function (value, description) {
+ var resultTag = createEl("p");
+ resultTag.className = result(value);
+ append(resultTag, text(description));
return resultTag;
};
- self.result = function (value) {
+ result = function (value) {
return value ? "pass" : "fail";
}
- self.groupNodeStatus = function (value, result) {
+ groupNodeStatus = function (value, result) {
if(!value) {
result.parentNode.parentNode.className = "fail";
}
}
- self.setStatusBarProgress = function (value, group) {
+ setStatusBarProgress = function (value, group) {
if (group) return;
var status = value ? ' . ' : ' F ';
- self.append(self.byId('status'), self.text(status));
+ append(byId('status'), text(status));
}
- self.pause = function () {
- self.paused = true;
+ pause = function () {
+ paused = true;
}
- self.resume = function () {
- self.paused = false;
- setTimeout(self.runTest, 1);
+ resume = function () {
+ paused = false;
+ setTimeout(runTest, 1);
}
- self.runTest = function () {
- if (!self.paused && self.queue.length) {
- self.queue.shift()();
- if (!self.paused) {
- self.resume();
+ runTest = function () {
+ if (!paused && queue.length) {
+ queue.shift()();
+ if (!paused) {
+ resume();
}
}
}
// some helper methods / shortcuts
- self.byId = function (id) {
+ byId = function (id) {
return document.getElementById(id);
}
- self.createEl = function (el) {
+ createEl = function (el) {
return document.createElement(el);
}
- self.text = function (text) {
+ text = function (text) {
return document.createTextNode(text);
}
- self.append = function(el, content) {
+ append = function(el, content) {
return el.appendChild(content);
}
return {
- createStatusBar: self.createStatusBar,
- intro: self.intro,
- assert: self.assert,
- test: self.test
+ createStatusBar: createStatusBar,
+ intro: intro,
+ assert: assert,
+ test: test
};
-} ();
+}) ();
Please sign in to comment.
Something went wrong with that request. Please try again.