dwf: refactoring how reporters work to add callbacks at all levels, separating how/when DOM writing works;
This commit is contained in:
@@ -1,27 +1,73 @@
|
||||
JasmineReporters.JSON = function (elementId) {
|
||||
var that = JasmineReporters.reporter(elementId);
|
||||
/*
|
||||
* JasmineReporters.JSON --
|
||||
* Basic reporter that keeps a JSON string of the most recent Spec, Suite or Runner
|
||||
* result. Calling application can then do whatever it wants/needs with the string;
|
||||
*/
|
||||
JasmineReporters.JSON = function () {
|
||||
var that = JasmineReporters.reporter();
|
||||
that.specJSON = '';
|
||||
that.suiteJSON = '';
|
||||
that.runnerJSON = '';
|
||||
|
||||
that.reportRunnerResults = function (results) {
|
||||
that.output = Object.toJSON(results);
|
||||
var saveSpecResults = function (results) {
|
||||
that.specJSON = Object.toJSON(results);
|
||||
}
|
||||
that.reportSpecResults = saveSpecResults;
|
||||
|
||||
if (that.element) {
|
||||
that.element.innerHTML += that.output;
|
||||
}
|
||||
}
|
||||
var saveSuiteResults = function (results) {
|
||||
that.suiteJSON = Object.toJSON(results);
|
||||
}
|
||||
that.reportSuiteResults = saveSuiteResults;
|
||||
|
||||
var saveRunnerResults = function (results) {
|
||||
that.runnerJSON = Object.toJSON(results);
|
||||
}
|
||||
that.reportRunnerResults = saveRunnerResults;
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
JasmineReporters.IncrementalJSON = function (elementId) {
|
||||
var that = JasmineReporters.reporter(elementId);
|
||||
var domWriter = function (elementId) {
|
||||
var that = {
|
||||
element: document.getElementById(elementId),
|
||||
|
||||
that.reportSpecResults = function (results) {
|
||||
that.output = Object.toJSON(results);
|
||||
if (that.element) {
|
||||
that.element.innerHTML += that.output;
|
||||
write: function (text) {
|
||||
if (that.element) {
|
||||
that.element.innerHTML += text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
that.element.innerHTML = '';
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
JasmineReporters.JSONtoDOM = function (elementId) {
|
||||
var that = JasmineReporters.JSON();
|
||||
|
||||
that.domWriter = domWriter(elementId);
|
||||
|
||||
var writeRunnerResults = function (results) {
|
||||
that.domWriter.write(Object.toJSON(results));
|
||||
};
|
||||
|
||||
that.reportRunnerResults = writeRunnerResults;
|
||||
|
||||
return that;
|
||||
}
|
||||
|
||||
|
||||
//JasmineReporters.IncrementalJSON = function (elementId) {
|
||||
// var that = JasmineReporters.reporter(elementId);
|
||||
//
|
||||
// that.reportSpecResults = function (results) {
|
||||
// that.output = Object.toJSON(results);
|
||||
// if (that.element) {
|
||||
// that.element.innerHTML += that.output;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return that;
|
||||
//}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user