dwf/rva: Added Incremental Reporter, refactored abstract reporter class, added tests! 78!!!

This commit is contained in:
pivotal
2008-12-04 12:54:54 -08:00
parent 8ee209585d
commit 80e1d6b6e8
5 changed files with 147 additions and 90 deletions

View File

@@ -58,7 +58,7 @@ var nestedResults = function() {
*
**/
var actionCollection = function () {
var that = {
var that = {
actions: [],
index: 0,
finished: false,
@@ -202,7 +202,15 @@ var it = function (description, func) {
that.currentTimeout = 0;
},
finishCallback: function () {
if (Jasmine.reporter) {
Jasmine.reporter.addSpecResults(that.results);
Jasmine.reporter.report();
}
},
finish: function() {
that.finishCallback();
that.finished = true;
},

View File

@@ -1,26 +1,44 @@
JasmineReporters.JSON = function (elementId) {
JasmineReporters.reporter = function (elementId) {
var that = {
elementId: elementId,
results: {},
element: document.getElementById(elementId),
output: '',
addResults: function (results) {
that.results = results;
},
addResults: function (results) { that.output = ''; },
addSpecResults: function (results) { that.output = ''; },
report: function () {
var output = Object.toJSON(that.results);
if (that.elementId) {
var element = document.getElementById(that.elementId);
if (element) {
element.innerHTML = output;
}
if (that.element) {
that.element.innerHTML += that.output;
}
return output;
return that.output;
}
}
// TODO: throw if no element?
if (that.element) {
that.element.innerHTML = '';
}
return that;
}
Jasmine.reporter = JasmineReporters.JSON();
JasmineReporters.JSON = function (elementId) {
var that = JasmineReporters.reporter(elementId);
that.addResults = function (results) {
that.output = Object.toJSON(results);
}
return that;
}
JasmineReporters.IncrementalJSON = function (elementId) {
var that = JasmineReporters.reporter(elementId);
that.addSpecResults = function (results) {
that.output = Object.toJSON(results);
}
return that;
}