79 lines
1.5 KiB
JavaScript
79 lines
1.5 KiB
JavaScript
getJasmineRequireObj().JsApiReporter = function() {
|
|
|
|
var noopTimer = {
|
|
start: function(){},
|
|
elapsed: function(){ return 0; }
|
|
};
|
|
|
|
function JsApiReporter(options) {
|
|
var timer = options.timer || noopTimer,
|
|
status = 'loaded';
|
|
|
|
this.started = false;
|
|
this.finished = false;
|
|
|
|
this.jasmineStarted = function() {
|
|
this.started = true;
|
|
status = 'started';
|
|
timer.start();
|
|
};
|
|
|
|
var executionTime;
|
|
|
|
this.jasmineDone = function() {
|
|
this.finished = true;
|
|
executionTime = timer.elapsed();
|
|
status = 'done';
|
|
};
|
|
|
|
this.status = function() {
|
|
return status;
|
|
};
|
|
|
|
var suites = [],
|
|
suites_hash = {};
|
|
|
|
this.suiteStarted = function(result) {
|
|
suites_hash[result.id] = result;
|
|
};
|
|
|
|
this.suiteDone = function(result) {
|
|
storeSuite(result);
|
|
};
|
|
|
|
this.suiteResults = function(index, length) {
|
|
return suites.slice(index, index + length);
|
|
};
|
|
|
|
function storeSuite(result) {
|
|
suites.push(result);
|
|
suites_hash[result.id] = result;
|
|
}
|
|
|
|
this.suites = function() {
|
|
return suites_hash;
|
|
};
|
|
|
|
var specs = [];
|
|
|
|
this.specDone = function(result) {
|
|
specs.push(result);
|
|
};
|
|
|
|
this.specResults = function(index, length) {
|
|
return specs.slice(index, index + length);
|
|
};
|
|
|
|
this.specs = function() {
|
|
return specs;
|
|
};
|
|
|
|
this.executionTime = function() {
|
|
return executionTime;
|
|
};
|
|
|
|
}
|
|
|
|
return JsApiReporter;
|
|
};
|