Skip to content

Commit

Permalink
Show message if no specs are found
Browse files Browse the repository at this point in the history
[#12784235]
  • Loading branch information
Christopher Amavisca, Greg Cobb and Luan Santos committed Mar 10, 2014
1 parent 1922514 commit af4cc76
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
14 changes: 11 additions & 3 deletions lib/jasmine-core/jasmine-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,18 @@ jasmineRequire.HtmlReporter = function(j$) {
)
);
}
var statusBarMessage = '' + pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
var statusBarMessage = '';
var statusBarClassName = 'bar ';

if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
} else {
statusBarClassName += 'skipped';
statusBarMessage += 'No specs found';
}

var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed');
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));

var results = find('.results');
Expand Down
27 changes: 24 additions & 3 deletions spec/html/HtmlReporterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,27 @@ describe("New HtmlReporter", function() {
});
});

it("shows a message if no specs are run", function(){
var env, container, reporter;
env = new j$.Env();
container = document.createElement("div");
var 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); }
});
reporter.initialize();

reporter.jasmineStarted({});
reporter.jasmineDone({});

var alertBars = container.querySelectorAll(".alert .bar");
expect(alertBars[0].getAttribute('class')).toMatch(/skipped/);
expect(alertBars[0].innerHTML).toMatch(/No specs found/);
});

describe("and all specs pass", function() {
var env, container, reporter;
beforeEach(function() {
Expand All @@ -401,7 +422,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();

reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 2 });
reporter.specDone({
id: 123,
description: "with a spec",
Expand Down Expand Up @@ -452,7 +473,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();

reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 1 });
reporter.specDone({
id: 123,
description: "with a spec",
Expand Down Expand Up @@ -490,7 +511,7 @@ describe("New HtmlReporter", function() {
});
reporter.initialize();

reporter.jasmineStarted({});
reporter.jasmineStarted({ totalSpecsDefined: 1 });

var passingResult = {id: 123, status: "passed"};
reporter.specStarted(passingResult);
Expand Down
14 changes: 11 additions & 3 deletions src/html/HtmlReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,18 @@ jasmineRequire.HtmlReporter = function(j$) {
)
);
}
var statusBarMessage = '' + pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
var statusBarMessage = '';
var statusBarClassName = 'bar ';

if (totalSpecsDefined > 0) {
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
} else {
statusBarClassName += 'skipped';
statusBarMessage += 'No specs found';
}

var statusBarClassName = 'bar ' + ((failureCount > 0) ? 'failed' : 'passed');
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));

var results = find('.results');
Expand Down

0 comments on commit af4cc76

Please sign in to comment.