Refactored into class files. Meta-tests and runner for jasmine. Stack traces available for Firefox and supported browsers. Experimental pretty print matcher support. Many other new features

This commit is contained in:
ragaskar
2009-05-28 20:02:15 -07:00
parent cabc666505
commit 9d95483de6
29 changed files with 3249 additions and 1717 deletions
+12 -39
View File
@@ -1,62 +1,35 @@
/*
* JasmineReporters.JSON --
* jasmine.Reporters.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;
*/
Jasmine.Reporters.JSON = function () {
jasmine.Reporters.JSON = function () {
var toJSON = function(object){
return JSON.stringify(object);
};
var that = Jasmine.Reporters.reporter();
var that = jasmine.Reporters.reporter();
that.specJSON = '';
that.suiteJSON = '';
that.runnerJSON = '';
var saveSpecResults = function (results) {
that.specJSON = toJSON(results);
var saveSpecResults = function (spec) {
that.specJSON = toJSON(spec.getResults());
};
that.reportSpecResults = saveSpecResults;
var saveSuiteResults = function (results) {
that.suiteJSON = toJSON(results);
var saveSuiteResults = function (suite) {
that.suiteJSON = toJSON(suite.getResults());
};
that.reportSuiteResults = saveSuiteResults;
var saveRunnerResults = function (results) {
that.runnerJSON = toJSON(results);
var saveRunnerResults = function (runner) {
that.runnerJSON = toJSON(runner.getResults());
};
that.reportRunnerResults = saveRunnerResults;
this.log = function (str) {
console.log(str);
};
that.toJSON = toJSON;
return that;
};
Jasmine.Reporters.domWriter = function (elementId) {
var that = {
element: document.getElementById(elementId),
write: function (text) {
if (that.element) {
that.element.innerHTML += text;
}
}
};
that.element.innerHTML = '';
return that;
};
Jasmine.Reporters.JSONtoDOM = function (elementId) {
var that = Jasmine.Reporters.JSON();
that.domWriter = Jasmine.Reporters.domWriter(elementId);
var writeRunnerResults = function (results) {
that.domWriter.write(that.toJSON(results));
};
that.reportRunnerResults = writeRunnerResults;
return that;
};