Remove 'empty' as an option as a spec result
- Having the 'empty' state for a spec result can be considered a breaking change to the reporter interface - Instead, we determine if a spec has no expectations using the added key of 'passedExpectations' in combination of the 'failedExpectations' to determine that there a spec is 'empty' [fixes #73741032]
This commit is contained in:
@@ -96,7 +96,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if(result.status == 'empty' && console && console.error) {
|
||||
if(noExpectations(result) && console && console.error) {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: result.status,
|
||||
className: noExpectations(result) ? 'empty' : result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
@@ -203,7 +203,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(resultNode.result.status == 'empty') {
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
@@ -298,6 +298,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
|
||||
@@ -253,7 +253,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
this.expectCalled = false;
|
||||
|
||||
if (!this.fn) {
|
||||
this.pend();
|
||||
@@ -269,7 +268,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.expectCalled = true;
|
||||
var expectationResult = this.expectationResultFactory(data);
|
||||
if (passed) {
|
||||
this.result.passedExpectations.push(expectationResult);
|
||||
@@ -343,10 +341,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
if(!this.expectCalled) {
|
||||
return 'empty';
|
||||
}
|
||||
|
||||
if (this.result.failedExpectations.length > 0) {
|
||||
return 'failed';
|
||||
} else {
|
||||
|
||||
@@ -194,10 +194,9 @@ describe("Spec", function() {
|
||||
expect(done).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("#status returns empty by default", function(){
|
||||
var emptySpec = new j$.Spec({ fn: function () {} });
|
||||
emptySpec.execute();
|
||||
expect(emptySpec.status()).toBe("empty");
|
||||
it("#status returns passing by default", function(){
|
||||
var spec = new j$.Spec({ fn: function () {} });
|
||||
expect(spec.status()).toBe("passed");
|
||||
});
|
||||
|
||||
it("#status returns passed if all expectations in the spec have passed", function() {
|
||||
|
||||
@@ -64,7 +64,7 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
|
||||
describe("when a spec is done", function() {
|
||||
it("logs errors to the console if it is an empty spec", function() {
|
||||
it("logs errors to the console and prints a special symbol if it is an empty spec", function() {
|
||||
if (!window.console) {
|
||||
window.console = { error: function(){} };
|
||||
}
|
||||
@@ -84,10 +84,14 @@ describe("New HtmlReporter", function() {
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({
|
||||
status: "empty",
|
||||
fullName: 'Some Name'
|
||||
status: "passed",
|
||||
fullName: 'Some Name',
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
|
||||
var specEl = container.querySelector('.symbol-summary li');
|
||||
expect(specEl.getAttribute("class")).toEqual("empty");
|
||||
});
|
||||
|
||||
it("reports the status symbol of a disabled spec", function() {
|
||||
@@ -102,7 +106,7 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles"});
|
||||
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles", passedExpectations: [], failedExpectations: []});
|
||||
|
||||
var specEl = container.querySelector('.symbol-summary li');
|
||||
expect(specEl.getAttribute("class")).toEqual("disabled");
|
||||
@@ -122,7 +126,7 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 789, status: "pending"});
|
||||
reporter.specDone({id: 789, status: "pending", passedExpectations: [], failedExpectations: []});
|
||||
|
||||
var specEl = container.querySelector('.symbol-summary li');
|
||||
expect(specEl.getAttribute("class")).toEqual("pending");
|
||||
@@ -141,7 +145,7 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({id: 123, status: "passed"});
|
||||
reporter.specDone({id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []});
|
||||
|
||||
var statuses = container.querySelector(".symbol-summary");
|
||||
var specEl = statuses.querySelector("li");
|
||||
@@ -195,15 +199,13 @@ describe("New HtmlReporter", function() {
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({});
|
||||
reporter.suiteStarted({id: 1});
|
||||
reporter.specStarted({
|
||||
status: "empty",
|
||||
id: 1,
|
||||
description: 'Spec Description'
|
||||
});
|
||||
reporter.specStarted({id: 1, status: 'passed', passedExpectations: [], failedExpectations: []});
|
||||
reporter.specDone({
|
||||
status: "empty",
|
||||
id: 1,
|
||||
description: 'Spec Description'
|
||||
status: 'passed',
|
||||
description: 'Spec Description',
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
reporter.suiteDone({id: 1});
|
||||
reporter.jasmineDone({});
|
||||
@@ -263,7 +265,9 @@ describe("New HtmlReporter", function() {
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "passed"
|
||||
status: "passed",
|
||||
failedExpectations: [],
|
||||
passedExpectations: [{passed: true}]
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
@@ -278,7 +282,9 @@ describe("New HtmlReporter", function() {
|
||||
id: 124,
|
||||
description: "with another spec",
|
||||
fullName: "A Suite inner suite with another spec",
|
||||
status: "passed"
|
||||
status: "passed",
|
||||
failedExpectations: [],
|
||||
passedExpectations: [{passed: true}]
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
reporter.specDone(specResult);
|
||||
@@ -290,7 +296,7 @@ describe("New HtmlReporter", function() {
|
||||
description: "with a failing spec",
|
||||
fullName: "A Suite inner with a failing spec",
|
||||
status: "failed",
|
||||
failedExpectations: [],
|
||||
failedExpectations: [{}],
|
||||
passedExpectations: []
|
||||
};
|
||||
reporter.specStarted(specResult);
|
||||
@@ -447,13 +453,17 @@ describe("New HtmlReporter", function() {
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "passed"
|
||||
status: "passed",
|
||||
passedExpectations: [{passed: true}],
|
||||
failedExpectations: []
|
||||
});
|
||||
reporter.specDone({
|
||||
id: 124,
|
||||
description: "with another spec",
|
||||
fullName: "A Suite inner suite with another spec",
|
||||
status: "passed"
|
||||
status: "passed",
|
||||
passedExpectations: [{passed: true}],
|
||||
failedExpectations: []
|
||||
});
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
@@ -498,7 +508,9 @@ describe("New HtmlReporter", function() {
|
||||
id: 123,
|
||||
description: "with a spec",
|
||||
fullName: "A Suite with a spec",
|
||||
status: "pending"
|
||||
status: "pending",
|
||||
passedExpectations: [],
|
||||
failedExpectations: []
|
||||
});
|
||||
reporter.jasmineDone({});
|
||||
});
|
||||
@@ -533,7 +545,7 @@ describe("New HtmlReporter", function() {
|
||||
|
||||
reporter.jasmineStarted({ totalSpecsDefined: 1 });
|
||||
|
||||
var passingResult = {id: 123, status: "passed"};
|
||||
var passingResult = {id: 123, status: "passed", passedExpectations: [{passed: true}], failedExpectations: []};
|
||||
reporter.specStarted(passingResult);
|
||||
reporter.specDone(passingResult);
|
||||
|
||||
@@ -542,6 +554,7 @@ describe("New HtmlReporter", function() {
|
||||
status: "failed",
|
||||
description: "a failing spec",
|
||||
fullName: "a suite with a failing spec",
|
||||
passedExpectations: [],
|
||||
failedExpectations: [
|
||||
{
|
||||
message: "a failure message",
|
||||
|
||||
@@ -13,7 +13,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
||||
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
||||
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
||||
this.expectCalled = false;
|
||||
|
||||
if (!this.fn) {
|
||||
this.pend();
|
||||
@@ -29,7 +28,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data) {
|
||||
this.expectCalled = true;
|
||||
var expectationResult = this.expectationResultFactory(data);
|
||||
if (passed) {
|
||||
this.result.passedExpectations.push(expectationResult);
|
||||
@@ -103,10 +101,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
if(!this.expectCalled) {
|
||||
return 'empty';
|
||||
}
|
||||
|
||||
if (this.result.failedExpectations.length > 0) {
|
||||
return 'failed';
|
||||
} else {
|
||||
|
||||
@@ -67,7 +67,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if(result.status == 'empty' && console && console.error) {
|
||||
if(noExpectations(result) && console && console.error) {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: result.status,
|
||||
className: noExpectations(result) ? 'empty' : result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
@@ -174,7 +174,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(resultNode.result.status == 'empty') {
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
@@ -269,6 +269,11 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
|
||||
Reference in New Issue
Block a user