JsApiReporter suiteResults only includes suite results

- It was including suite starts also

[#79533268]
This commit is contained in:
Gerg
2014-10-08 22:33:36 -07:00
parent 9ad15eeaba
commit 8880729250
3 changed files with 17 additions and 7 deletions

View File

@@ -564,6 +564,7 @@ getJasmineRequireObj().Env = function(j$) {
options.catchException = catchException; options.catchException = catchException;
options.clearStack = options.clearStack || clearStack; options.clearStack = options.clearStack || clearStack;
options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
options.fail = self.fail;
new j$.QueueRunner(options).execute(); new j$.QueueRunner(options).execute();
}; };
@@ -744,7 +745,6 @@ getJasmineRequireObj().Env = function(j$) {
userContext: function() { return suite.clonedSharedUserContext(); }, userContext: function() { return suite.clonedSharedUserContext(); },
queueableFn: { queueableFn: {
fn: fn, fn: fn,
type: 'it',
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
} }
}); });
@@ -801,7 +801,6 @@ getJasmineRequireObj().Env = function(j$) {
this.beforeEach = function(beforeEachFunction, timeout) { this.beforeEach = function(beforeEachFunction, timeout) {
currentDeclarationSuite.beforeEach({ currentDeclarationSuite.beforeEach({
fn: beforeEachFunction, fn: beforeEachFunction,
type: 'beforeEach',
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
}); });
}; };
@@ -809,7 +808,6 @@ getJasmineRequireObj().Env = function(j$) {
this.beforeAll = function(beforeAllFunction, timeout) { this.beforeAll = function(beforeAllFunction, timeout) {
currentDeclarationSuite.beforeAll({ currentDeclarationSuite.beforeAll({
fn: beforeAllFunction, fn: beforeAllFunction,
type: 'beforeAll',
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
}); });
}; };
@@ -817,7 +815,6 @@ getJasmineRequireObj().Env = function(j$) {
this.afterEach = function(afterEachFunction, timeout) { this.afterEach = function(afterEachFunction, timeout) {
currentDeclarationSuite.afterEach({ currentDeclarationSuite.afterEach({
fn: afterEachFunction, fn: afterEachFunction,
type: 'afterEach',
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
}); });
}; };
@@ -825,7 +822,6 @@ getJasmineRequireObj().Env = function(j$) {
this.afterAll = function(afterAllFunction, timeout) { this.afterAll = function(afterAllFunction, timeout) {
currentDeclarationSuite.afterAll({ currentDeclarationSuite.afterAll({
fn: afterAllFunction, fn: afterAllFunction,
type: 'afterAll',
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
}); });
}; };
@@ -890,7 +886,7 @@ getJasmineRequireObj().JsApiReporter = function() {
suites_hash = {}; suites_hash = {};
this.suiteStarted = function(result) { this.suiteStarted = function(result) {
storeSuite(result); suites_hash[result.id] = result;
}; };
this.suiteDone = function(result) { this.suiteDone = function(result) {
@@ -1728,6 +1724,7 @@ getJasmineRequireObj().QueueRunner = function(j$) {
this.catchException = attrs.catchException || function() { return true; }; this.catchException = attrs.catchException || function() { return true; };
this.userContext = attrs.userContext || {}; this.userContext = attrs.userContext || {};
this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
this.fail = attrs.fail || function() {};
} }
QueueRunner.prototype.execute = function() { QueueRunner.prototype.execute = function() {
@@ -1773,6 +1770,11 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}), }),
timeoutId; timeoutId;
next.fail = function() {
self.fail.apply(null, arguments);
next();
};
if (queueableFn.timeout) { if (queueableFn.timeout) {
timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');

View File

@@ -182,6 +182,9 @@ describe("JsApiReporter", function() {
var reporter, suiteResult1, suiteResult2; var reporter, suiteResult1, suiteResult2;
beforeEach(function() { beforeEach(function() {
reporter = new j$.JsApiReporter({}); reporter = new j$.JsApiReporter({});
suiteStarted1 = {
id: 1
};
suiteResult1 = { suiteResult1 = {
id: 1, id: 1,
status: 'failed', status: 'failed',
@@ -192,10 +195,15 @@ describe("JsApiReporter", function() {
status: 'finished' status: 'finished'
}; };
reporter.suiteStarted(suiteStarted1);
reporter.suiteDone(suiteResult1); reporter.suiteDone(suiteResult1);
reporter.suiteDone(suiteResult2); reporter.suiteDone(suiteResult2);
}); });
it('should not include suite starts', function(){
expect(reporter.suiteResults(0,3).length).toEqual(2);
});
it("should return a slice of results", function() { it("should return a slice of results", function() {
expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]); expect(reporter.suiteResults(0, 1)).toEqual([suiteResult1]);
expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]); expect(reporter.suiteResults(1, 1)).toEqual([suiteResult2]);

View File

@@ -34,7 +34,7 @@ getJasmineRequireObj().JsApiReporter = function() {
suites_hash = {}; suites_hash = {};
this.suiteStarted = function(result) { this.suiteStarted = function(result) {
storeSuite(result); suites_hash[result.id] = result;
}; };
this.suiteDone = function(result) { this.suiteDone = function(result) {