jasmine.TrivialReporter = function(doc) { this.document = doc || document; this.suiteDivs = {}; }; jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) { var el = document.createElement(type); for (var i = 2; i < arguments.length; i++) { var child = arguments[i]; if (typeof child === 'string') { el.appendChild(document.createTextNode(child)); } else { if (child) { el.appendChild(child); } } } for (var attr in attrs) { el[attr] = attrs[attr]; } return el; }; jasmine.TrivialReporter.prototype._argString = function(s) { // Maintain non-"spec" arguments var undefined; if(this.specs == undefined){ this.specs = "?"; var args = window.location.href; args = args.split('?'); if(args.length>1){ args = args[1].split("&"); var map = {}; for(var i=0; i 0) ? "runner failed" : "runner passed"; this.runnerDiv.setAttribute("class", className); //do it twice for IE this.runnerDiv.setAttribute("className", className); var specs = runner.specs(); var specCount = 0; for (var i = 0; i < specs.length; i++) { if (this.specFilter(specs[i])) { specCount++; } } var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: this._argString()}, message), this.runnerMessageSpan.firstChild); }; jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { var results = suite.results(); var status = results.passed() ? 'passed' : 'failed'; if (results.totalCount == 0) { // todo: change this to check results.skipped status = 'skipped'; } this.suiteDivs[suite.getFullName()].className += " " + status; }; jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { var results = spec.results(); var status = results.passed() ? 'passed' : 'failed'; if (results.skipped) { status = 'skipped'; } var specDiv = this.createDom('div', { className: 'spec ' + status }, this.createDom('a', { className: 'run_spec', href: this._argString(encodeURIComponent(spec.getFullName())) }, "run"), this.createDom('a', { className: 'description', href: this._argString(encodeURIComponent(spec.getFullName())) }, spec.getFullName())); var resultItems = results.getItems(); for (var i = 0; i < resultItems.length; i++) { var result = resultItems[i]; if (result.passed && !result.passed()) { specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); } } this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); }; jasmine.TrivialReporter.prototype.log = function() { this.console && console.log.apply(console, arguments); }; jasmine.TrivialReporter.prototype.getLocation = function() { return this.document.location; }; jasmine.TrivialReporter.prototype.specFilter = function(spec) { var paramMap = {}; var params = this.getLocation().search.substring(1).split('&'); for (var i = 0; i < params.length; i++) { var p = params[i].split('='); paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); } if (!paramMap["spec"]) return true; return spec.getFullName().indexOf(decodeURIComponent(paramMap["spec"])) == 0; };