Adds suiteResults method to JsApiReporter

- Behaves similarly to to specResults
- Since suites were stored in an object instead of an array and the
  current interface exposes this object, we now must keep track of suites
  twice in the reporter. We cannot just construct the object lazily,
  because then the object will not update with new suite results
  like it does currently (see JsApiReporterSpec:148).

[#79533268]
This commit is contained in:
Gerg
2014-10-04 18:34:59 -07:00
parent f4e5573ee3
commit b12974db2e
4 changed files with 59 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@@ -886,7 +886,8 @@ getJasmineRequireObj().JsApiReporter = function() {
return status;
};
var suites = {};
var suites = [],
suites_hash = {};
this.suiteStarted = function(result) {
storeSuite(result);
@@ -896,16 +897,20 @@ getJasmineRequireObj().JsApiReporter = function() {
storeSuite(result);
};
this.suiteResults = function(index, length) {
return suites.slice(index, index + length);
};
function storeSuite(result) {
suites[result.id] = result;
suites.push(result);
suites_hash[result.id] = result;
}
this.suites = function() {
return suites;
return suites_hash;
};
var specs = [];
this.specStarted = function(result) { };
this.specDone = function(result) {
specs.push(result);

View File

@@ -178,6 +178,37 @@ describe("JsApiReporter", function() {
});
});
describe("#suiteResults", function(){
var reporter, suiteResult1, suiteResult2;
beforeEach(function() {
reporter = new j$.JsApiReporter({});
suiteResult1 = {
id: 1,
status: 'failed',
failedExpectations: [{ message: 'My After All Exception' }]
};
suiteResult2 = {
id: 2,
status: 'finished'
};
reporter.suiteDone(suiteResult1);
reporter.suiteDone(suiteResult2);
});
it("should return a slice of results", function() {
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);
});
describe("when the results do not exist", function() {
it("should return a slice of shorter length", function() {
expect(reporter.suiteResults(0, 3)).toEqual([suiteResult1, suiteResult2]);
expect(reporter.suiteResults(2, 3)).toEqual([]);
});
});
});
describe("#executionTime", function() {
it("should start the timer when jasmine starts", function() {
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),

View File

@@ -30,7 +30,8 @@ getJasmineRequireObj().JsApiReporter = function() {
return status;
};
var suites = {};
var suites = [],
suites_hash = {};
this.suiteStarted = function(result) {
storeSuite(result);
@@ -40,16 +41,20 @@ getJasmineRequireObj().JsApiReporter = function() {
storeSuite(result);
};
this.suiteResults = function(index, length) {
return suites.slice(index, index + length);
};
function storeSuite(result) {
suites[result.id] = result;
suites.push(result);
suites_hash[result.id] = result;
}
this.suites = function() {
return suites;
return suites_hash;
};
var specs = [];
this.specStarted = function(result) { };
this.specDone = function(result) {
specs.push(result);