lib/teaspoon/qunit/assets/teaspoon-qunit.js in teaspoon-qunit-1.18.0 vs lib/teaspoon/qunit/assets/teaspoon-qunit.js in teaspoon-qunit-1.19.0
- old
+ new
@@ -78,11 +78,11 @@
Teaspoon.log = function() {
var e;
Teaspoon.messages.push(arguments[0]);
try {
- return console.log.apply(console, arguments);
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log.apply(console, arguments) : void 0 : void 0;
} catch (_error) {
e = _error;
throw new Error("Unable to use console.log for logging");
}
};
@@ -126,10 +126,50 @@
})();
}).call(this);
(function() {
+ Teaspoon.Mixins || (Teaspoon.Mixins = {});
+
+}).call(this);
+(function() {
+ Teaspoon.Mixins.FilterUrl = {
+ filterUrl: function(grep) {
+ var params;
+ params = [];
+ params.push("grep=" + (encodeURIComponent(grep)));
+ if (Teaspoon.params.file) {
+ params.push("file=" + Teaspoon.params.file);
+ }
+ return "?" + (params.join("&"));
+ }
+ };
+
+}).call(this);
+(function() {
+ Teaspoon.Utility = (function() {
+ function Utility() {}
+
+ Utility.extend = function(obj, mixin) {
+ var method, name;
+ for (name in mixin) {
+ method = mixin[name];
+ obj[name] = method;
+ }
+ return obj;
+ };
+
+ Utility.include = function(klass, mixin) {
+ return this.extend(klass.prototype, mixin);
+ };
+
+ return Utility;
+
+ })();
+
+}).call(this);
+(function() {
Teaspoon.Runner = (function() {
Runner.run = false;
function Runner() {
if (this.constructor.run) {
@@ -178,61 +218,61 @@
}).call(this);
(function() {
var slice = [].slice;
Teaspoon.Fixture = (function() {
- var addContent, cleanup, create, load, loadComplete, preload, putContent, set, xhr, xhrRequest;
+ var addContent, cleanup, create, jQueryAvailable, load, loadComplete, preload, putContent, set, xhr, xhrRequest;
Fixture.cache = {};
Fixture.el = null;
Fixture.$el = null;
Fixture.json = [];
Fixture.preload = function() {
- var i, len, results, url, urls;
+ var j, len, results, url, urls;
urls = 1 <= arguments.length ? slice.call(arguments, 0) : [];
results = [];
- for (i = 0, len = urls.length; i < len; i++) {
- url = urls[i];
+ for (j = 0, len = urls.length; j < len; j++) {
+ url = urls[j];
results.push(preload(url));
}
return results;
};
Fixture.load = function() {
- var append, i, index, j, len, results, url, urls;
- urls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
+ var append, index, j, k, len, results, url, urls;
+ urls = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), append = arguments[j++];
if (append == null) {
append = false;
}
if (typeof append !== "boolean") {
urls.push(append);
append = false;
}
results = [];
- for (index = j = 0, len = urls.length; j < len; index = ++j) {
+ for (index = k = 0, len = urls.length; k < len; index = ++k) {
url = urls[index];
results.push(load(url, append || index > 0));
}
return results;
};
Fixture.set = function() {
- var append, html, htmls, i, index, j, len, results;
- htmls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
+ var append, html, htmls, index, j, k, len, results;
+ htmls = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), append = arguments[j++];
if (append == null) {
append = false;
}
if (typeof append !== "boolean") {
htmls.push(append);
append = false;
}
results = [];
- for (index = j = 0, len = htmls.length; j < len; index = ++j) {
+ for (index = k = 0, len = htmls.length; k < len; index = ++k) {
html = htmls[index];
results.push(set(html, append || index > 0));
}
return results;
};
@@ -299,25 +339,34 @@
}
};
putContent = function(content) {
cleanup();
- create();
- return window.fixture.el.innerHTML = content;
+ return addContent(content);
};
addContent = function(content) {
+ var i, j, parsed, ref, results;
if (!window.fixture.el) {
create();
}
- return window.fixture.el.innerHTML += content;
+ if (jQueryAvailable()) {
+ parsed = $($.parseHTML(content, document, true));
+ results = [];
+ for (i = j = 0, ref = parsed.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
+ results.push(window.fixture.el.appendChild(parsed[i]));
+ }
+ return results;
+ } else {
+ return window.fixture.el.innerHTML += content;
+ }
};
create = function() {
var ref;
window.fixture.el = document.createElement("div");
- if (typeof window.$ === 'function') {
+ if (jQueryAvailable()) {
window.fixture.$el = $(window.fixture.el);
}
window.fixture.el.id = "teaspoon-fixtures";
return (ref = document.body) != null ? ref.appendChild(window.fixture.el) : void 0;
};
@@ -355,10 +404,14 @@
xhr.onreadystatechange = callback;
xhr.open("GET", Teaspoon.root + "/fixtures/" + url, false);
return xhr.send();
};
+ jQueryAvailable = function() {
+ return typeof window.$ === 'function';
+ };
+
return Fixture;
})();
}).call(this);
@@ -405,10 +458,32 @@
});
};
}).call(this);
(function() {
+ Teaspoon.Spec = (function() {
+ function Spec() {}
+
+ Teaspoon.Utility.include(Spec, Teaspoon.Mixins.FilterUrl);
+
+ return Spec;
+
+ })();
+
+}).call(this);
+(function() {
+ Teaspoon.Suite = (function() {
+ function Suite() {}
+
+ Teaspoon.Utility.include(Suite, Teaspoon.Mixins.FilterUrl);
+
+ return Suite;
+
+ })();
+
+}).call(this);
+(function() {
Teaspoon.Reporters.BaseView = (function() {
function BaseView() {
this.elements = {};
this.build();
}
@@ -545,11 +620,11 @@
this.setStatus("passed");
}
this.setText("stats-passes", this.total.passes);
this.setText("stats-failures", this.total.failures);
if (this.total.run < this.total.exist) {
- this.total.skipped = this.total.exist - this.total.run;
+ this.total.skipped = this.total.exist - this.total.run + this.total.skipped;
this.total.run = this.total.exist;
}
this.setText("stats-skipped", this.total.skipped);
return this.updateProgress();
};
@@ -566,11 +641,12 @@
};
HTML.prototype.reportSpecResults = function(spec) {
this.total.run += 1;
this.updateProgress();
- return this.updateStatus(spec);
+ this.updateStatus(spec);
+ return delete this.reportView;
};
HTML.prototype.buildLayout = function() {
var el;
el = this.createEl("div");
@@ -621,31 +697,28 @@
}
return this.setText("stats-" + name, value);
};
HTML.prototype.updateStatus = function(spec) {
- var elapsed, ref, ref1, ref2, result;
- result = spec.result();
- if (result.skipped) {
- this.updateStat("skipped", this.total.skipped += 1);
- return;
- }
+ var elapsed, ref, result;
elapsed = new Teaspoon.Date().getTime() - this.specStart;
- if (result.status === "passed") {
- this.updateStat("passes", this.total.passes += 1);
- return (ref = this.reportView) != null ? ref.updateState("passed", elapsed) : void 0;
- } else if (result.status === "pending") {
- return (ref1 = this.reportView) != null ? ref1.updateState("pending", elapsed) : void 0;
- } else {
+ if ((ref = this.reportView) != null) {
+ ref.updateState(spec, elapsed);
+ }
+ result = spec.result();
+ if (result.status === "pending") {
+ return this.updateStat("skipped", this.total.skipped += 1);
+ } else if (result.status === "failed") {
this.updateStat("failures", this.total.failures += 1);
- if ((ref2 = this.reportView) != null) {
- ref2.updateState("failed", elapsed);
- }
if (!this.config["build-full-report"]) {
new (Teaspoon.resolveClass("Reporters.HTML.FailureView"))(spec).appendTo(this.findEl("report-failures"));
}
return this.setStatus("failed");
+ } else if (result.skipped) {
+ return this.updateStat("skipped", this.total.skipped += 1);
+ } else {
+ return this.updateStat("passes", this.total.passes += 1);
}
};
HTML.prototype.updateProgress = function() {
return this.progress.update(this.total.exist, this.total.run);
@@ -894,12 +967,12 @@
extend(SpecView, superClass);
viewId = 0;
- function SpecView(spec, reporter) {
- this.spec = spec;
+ function SpecView(spec1, reporter) {
+ this.spec = spec1;
this.reporter = reporter;
this.views = this.reporter.views;
this.spec.viewId = viewId += 1;
this.views.specs[this.spec.viewId] = this;
SpecView.__super__.constructor.apply(this, arguments);
@@ -918,10 +991,13 @@
};
SpecView.prototype.buildParent = function() {
var parent, view;
parent = this.spec.parent;
+ if (!parent) {
+ return this.reporter;
+ }
if (parent.viewId) {
return this.views.suites[parent.viewId];
} else {
view = new (Teaspoon.resolveClass("Reporters.HTML.SuiteView"))(parent, this.reporter);
return this.views.suites[view.suite.viewId] = view;
@@ -939,27 +1015,58 @@
}
div.innerHTML = html;
return this.append(div);
};
- SpecView.prototype.updateState = function(state, elapsed) {
- var base, classes, result;
- result = this.spec.result();
- classes = ["state-" + state];
+ SpecView.prototype.updateState = function(spec, elapsed) {
+ var result;
+ result = spec.result();
+ this.clearClasses();
+ if (result.status === "pending") {
+ return this.updatePending(spec, elapsed);
+ } else if (result.status === "failed") {
+ return this.updateFailed(spec, elapsed);
+ } else if (result.skipped) {
+ return this.updateDisabled(spec, elapsed);
+ } else {
+ return this.updatePassed(spec, elapsed);
+ }
+ };
+
+ SpecView.prototype.updatePassed = function(spec, elapsed) {
+ this.addStatusClass("passed");
if (elapsed > Teaspoon.slow) {
- classes.push("slow");
+ this.addClass("slow");
}
- if (state === "passed") {
- this.el.innerHTML += "<span>" + elapsed + "ms</span>";
- }
- this.el.className = classes.join(" ");
- if (result.status === "failed") {
- this.buildErrors();
- }
- return typeof (base = this.parentView).updateState === "function" ? base.updateState(state) : void 0;
+ return this.el.innerHTML += "<span>" + elapsed + "ms</span>";
};
+ SpecView.prototype.updateFailed = function(spec, elapsed) {
+ var base;
+ this.addStatusClass("failed");
+ this.buildErrors();
+ return typeof (base = this.parentView).updateState === "function" ? base.updateState("failed") : void 0;
+ };
+
+ SpecView.prototype.updatePending = function(spec, elapsed) {
+ return this.addStatusClass("pending");
+ };
+
+ SpecView.prototype.updateDisabled = function(spec, elapsed) {};
+
+ SpecView.prototype.clearClasses = function() {
+ return this.el.className = "";
+ };
+
+ SpecView.prototype.addStatusClass = function(status) {
+ return this.addClass("state-" + status);
+ };
+
+ SpecView.prototype.addClass = function(name) {
+ return this.el.className += " " + name;
+ };
+
return SpecView;
})(Teaspoon.Reporters.BaseView);
}).call(this);
@@ -1089,63 +1196,70 @@
Console.prototype.reportSpecResults = function(spec1) {
var result;
this.spec = spec1;
result = this.spec.result();
- if (result.skipped) {
- return;
+ if (result.status === "pending") {
+ return this.trackPending(this.spec);
+ } else if (result.status === "failed") {
+ return this.trackFailed(this.spec);
+ } else if (result.skipped) {
+ return this.trackDisabled(this.spec);
+ } else {
+ return this.trackPassed(this.spec);
}
- this.reportSuites();
- switch (result.status) {
- case "pending":
- return this.trackPending();
- case "failed":
- return this.trackFailure();
- default:
- return this.log({
- type: "spec",
- suite: this.spec.suiteName,
- label: this.spec.description,
- status: result.status,
- skipped: result.skipped
- });
- }
};
- Console.prototype.trackPending = function() {
+ Console.prototype.trackPending = function(spec) {
var result;
- result = this.spec.result();
+ this.reportSuites();
+ result = spec.result();
return this.log({
type: "spec",
- suite: this.spec.suiteName,
- label: this.spec.description,
+ suite: spec.suiteName,
+ label: spec.description,
status: result.status,
skipped: result.skipped
});
};
- Console.prototype.trackFailure = function() {
+ Console.prototype.trackFailed = function(spec) {
var error, i, len, ref, result, results;
- result = this.spec.result();
- ref = this.spec.errors();
+ this.reportSuites();
+ result = spec.result();
+ ref = spec.errors();
results = [];
for (i = 0, len = ref.length; i < len; i++) {
error = ref[i];
results.push(this.log({
type: "spec",
- suite: this.spec.suiteName,
- label: this.spec.description,
+ suite: spec.suiteName,
+ label: spec.description,
status: result.status,
skipped: result.skipped,
- link: this.spec.fullDescription,
+ link: spec.fullDescription,
message: error.message,
trace: error.stack || error.message || "Stack Trace Unavailable"
}));
}
return results;
};
+ Console.prototype.trackDisabled = function(spec) {};
+
+ Console.prototype.trackPassed = function(spec, result) {
+ this.reportSuites();
+ result = spec.result();
+ return this.log({
+ type: "spec",
+ suite: spec.suiteName,
+ label: spec.description,
+ status: result.status,
+ skipped: result.skipped
+ });
+ };
+
Console.prototype.log = function(obj) {
if (obj == null) {
obj = {};
}
obj["_teaspoon"] = true;
@@ -1422,16 +1536,21 @@
})(Teaspoon.Runner);
}).call(this);
(function() {
- Teaspoon.Qunit.Spec = (function() {
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ hasProp = {}.hasOwnProperty;
+
+ Teaspoon.Qunit.Spec = (function(superClass) {
+ extend(Spec, superClass);
+
function Spec(spec1) {
this.spec = spec1;
this.fullDescription = this.spec.module + " " + this.spec.name;
this.description = this.spec.name + " (" + this.spec.failed + ", " + this.spec.passed + ", " + this.spec.total + ")";
- this.link = "?grep=" + (encodeURIComponent(this.spec.module + ": " + this.spec.name));
+ this.link = this.filterUrl(this.spec.module + ": " + this.spec.name);
this.parent = this.spec.module ? new Teaspoon.Qunit.Suite({
description: this.spec.module
}) : null;
this.suiteName = this.spec.module;
this.viewId = this.spec.viewId;
@@ -1489,11 +1608,11 @@
}
};
return Spec;
- })();
+ })(Teaspoon.Spec);
Teaspoon.Spec = (function() {
function Spec(spec) {
return spec;
}
@@ -1502,28 +1621,24 @@
})();
}).call(this);
(function() {
- Teaspoon.Qunit.Suite = (function() {
- function Suite(suite1) {
- this.suite = suite1;
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+ hasProp = {}.hasOwnProperty;
+
+ Teaspoon.Qunit.Suite = (function(superClass) {
+ extend(Suite, superClass);
+
+ function Suite(suite) {
+ this.suite = suite;
this.fullDescription = this.suite.description || this.suite.name;
this.description = this.suite.description || this.suite.name;
- this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
+ this.link = this.filterUrl(this.fullDescription);
this.parent = null;
}
return Suite;
- })();
-
- Teaspoon.Suite = (function() {
- function Suite(suite) {
- return new Teaspoon.Qunit.Suite(suite);
- }
-
- return Suite;
-
- })();
+ })(Teaspoon.Suite);
}).call(this);