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
+34 -16
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;
}