2008-12-08 19:35:10 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
*/
|
2008-12-08 21:01:06 +00:00
|
|
|
Jasmine.Reporters.JSON = function () {
|
|
|
|
var that = Jasmine.Reporters.reporter();
|
2008-12-08 19:35:10 +00:00
|
|
|
that.specJSON = '';
|
|
|
|
that.suiteJSON = '';
|
|
|
|
that.runnerJSON = '';
|
2008-12-04 20:54:54 +00:00
|
|
|
|
2008-12-08 19:35:10 +00:00
|
|
|
var saveSpecResults = function (results) {
|
|
|
|
that.specJSON = Object.toJSON(results);
|
|
|
|
}
|
|
|
|
that.reportSpecResults = saveSpecResults;
|
2008-12-06 01:33:35 +00:00
|
|
|
|
2008-12-08 19:35:10 +00:00
|
|
|
var saveSuiteResults = function (results) {
|
|
|
|
that.suiteJSON = Object.toJSON(results);
|
|
|
|
}
|
|
|
|
that.reportSuiteResults = saveSuiteResults;
|
|
|
|
|
|
|
|
var saveRunnerResults = function (results) {
|
|
|
|
that.runnerJSON = Object.toJSON(results);
|
|
|
|
}
|
|
|
|
that.reportRunnerResults = saveRunnerResults;
|
2008-12-04 20:54:54 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
}
|
|
|
|
|
2008-12-08 21:01:06 +00:00
|
|
|
Jasmine.Reporters.domWriter = function (elementId) {
|
2008-12-08 19:35:10 +00:00
|
|
|
var that = {
|
|
|
|
element: document.getElementById(elementId),
|
2008-12-04 20:54:54 +00:00
|
|
|
|
2008-12-08 19:35:10 +00:00
|
|
|
write: function (text) {
|
|
|
|
if (that.element) {
|
|
|
|
that.element.innerHTML += text;
|
2008-12-06 01:33:35 +00:00
|
|
|
}
|
2008-12-08 19:35:10 +00:00
|
|
|
}
|
2008-12-04 20:54:54 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 19:35:10 +00:00
|
|
|
that.element.innerHTML = '';
|
|
|
|
|
2008-12-04 20:54:54 +00:00
|
|
|
return that;
|
2008-12-06 01:33:35 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 21:01:06 +00:00
|
|
|
Jasmine.Reporters.JSONtoDOM = function (elementId) {
|
|
|
|
var that = Jasmine.Reporters.JSON();
|
2008-12-08 19:35:10 +00:00
|
|
|
|
2008-12-08 21:01:06 +00:00
|
|
|
that.domWriter = Jasmine.Reporters.domWriter(elementId);
|
2008-12-08 19:35:10 +00:00
|
|
|
|
|
|
|
var writeRunnerResults = function (results) {
|
|
|
|
that.domWriter.write(Object.toJSON(results));
|
|
|
|
};
|
|
|
|
|
|
|
|
that.reportRunnerResults = writeRunnerResults;
|
|
|
|
|
|
|
|
return that;
|
|
|
|
}
|