Specs without expectations should be alerted to the user
- Add console.error to the HtmlReporter when there is a spec without any expectation - Change the spec's link text and color to include a warning - Create a status for specs to label them as "empty" - console is not accessible to IE unless you have developer tools open, so protect against that by mocking console. [#59424794]
This commit is contained in:
parent
71dbffeaef
commit
1922514f2d
@@ -46,6 +46,32 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
|
||||
describe("when a spec is done", function() {
|
||||
it("logs errors to the console if it is an empty spec", function() {
|
||||
if (!window.console) {
|
||||
window.console = { error: function(){} };
|
||||
}
|
||||
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement('div'),
|
||||
getContainer = function() {return container;},
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
reporter.initialize();
|
||||
|
||||
reporter.specDone({
|
||||
status: "empty",
|
||||
fullName: 'Some Name'
|
||||
});
|
||||
expect(console.error).toHaveBeenCalledWith("Spec \'Some Name\' has no expectations.");
|
||||
});
|
||||
|
||||
it("reports the status symbol of a disabled spec", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
@@ -131,6 +157,46 @@ describe("New HtmlReporter", function() {
|
||||
});
|
||||
|
||||
describe("when Jasmine is done", function() {
|
||||
it("adds EMPTY to the link title of specs that have no expectations", function() {
|
||||
if (!window.console) {
|
||||
window.console = { error: function(){} };
|
||||
}
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement('div'),
|
||||
getContainer = function() {return container;},
|
||||
reporter = new j$.HtmlReporter({
|
||||
env: env,
|
||||
getContainer: getContainer,
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
||||
});
|
||||
|
||||
spyOn(console, 'error');
|
||||
|
||||
reporter.initialize();
|
||||
reporter.jasmineStarted({});
|
||||
reporter.suiteStarted({id: 1});
|
||||
reporter.specStarted({
|
||||
status: "empty",
|
||||
id: 1,
|
||||
description: 'Spec Description'
|
||||
});
|
||||
reporter.specDone({
|
||||
status: "empty",
|
||||
id: 1,
|
||||
description: 'Spec Description'
|
||||
});
|
||||
reporter.suiteDone({id: 1});
|
||||
reporter.jasmineDone({});
|
||||
|
||||
var summary = container.querySelector('.summary');
|
||||
var suite = summary.childNodes[0];
|
||||
var specs = suite.childNodes[1];
|
||||
var spec = specs.childNodes[0];
|
||||
var specLink = spec.childNodes[0];
|
||||
expect(specLink.innerHTML).toMatch(/SPEC HAS NO EXPECTATIONS/);
|
||||
});
|
||||
|
||||
it("reports the run time", function() {
|
||||
var env = new j$.Env(),
|
||||
container = document.createElement("div"),
|
||||
|
||||
Reference in New Issue
Block a user