jasmine-headless-webkit/vendor/assets/javascripts/jasmine.HeadlessReporter.js

78 lines
2.1 KiB
JavaScript
Raw Normal View History

2011-12-29 23:37:23 +00:00
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
2011-12-12 17:22:32 +00:00
if (!(typeof jasmine !== "undefined" && jasmine !== null)) {
throw new Error("jasmine not loaded!");
}
jasmine.HeadlessReporter = (function() {
2011-12-29 23:37:23 +00:00
function HeadlessReporter(outputTarget) {
this.outputTarget = outputTarget != null ? outputTarget : null;
this.puts = __bind(this.puts, this);
this.print = __bind(this.print, this);
2011-12-12 17:22:32 +00:00
this.results = [];
this.failedCount = 0;
this.length = 0;
this.timer = null;
}
HeadlessReporter.prototype.hasError = function() {
return JHW._hasErrors;
};
HeadlessReporter.prototype.reportSpecStarting = function(spec) {
if (this.hasError()) {
spec.finish();
return spec.suite.finish();
}
};
HeadlessReporter.prototype.reportSuiteResults = function(suite) {};
HeadlessReporter.prototype.reportRunnerStarting = function(runner) {
return this.startTime = new Date();
};
HeadlessReporter.prototype.reportRunnerResults = function(runner) {
if (this.hasError()) return;
if (this.failedCount !== 0) JHW.hasSpecFailure();
2011-12-29 23:37:23 +00:00
JHW.finishSuite();
if (window.JHW) return window.onbeforeunload = null;
2011-12-12 17:22:32 +00:00
};
HeadlessReporter.prototype.reportSpecResults = function(spec) {
if (this.hasError()) return;
return JHW.ping();
};
HeadlessReporter.prototype._reportSpecResult = function(spec, options) {
var results;
results = spec.results();
this.length++;
if (results.passed()) {
return options.success(results, spec);
} else {
this.failedCount++;
return options.failure(results, spec);
}
};
HeadlessReporter.prototype._runtime = function() {
return (new Date() - this.startTime) / 1000.0;
};
2011-12-29 23:37:23 +00:00
HeadlessReporter.prototype.print = function(output) {
return JHW.print(this.outputTarget, output);
};
HeadlessReporter.prototype.puts = function(output) {
return JHW.print(this.outputTarget, output + "\n");
};
2011-12-12 17:22:32 +00:00
return HeadlessReporter;
})();
2011-12-29 23:37:23 +00:00
}).call(this);