Merge commit '5f10b2e623c6c21d1b692bde4a8a5c6d4015cd44'
This commit is contained in:
commit
2212d755c3
|
@ -17,7 +17,11 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var attr in attrs) {
|
for (var attr in attrs) {
|
||||||
|
if (attr == "className") {
|
||||||
el[attr] = attrs[attr];
|
el[attr] = attrs[attr];
|
||||||
|
} else {
|
||||||
|
el.setAttribute(attr, attrs[attr]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return el;
|
return el;
|
||||||
|
@ -26,10 +30,29 @@ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarA
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
var suites = runner.suites();
|
var suites = runner.suites();
|
||||||
|
|
||||||
|
var showPassed, showSkipped;
|
||||||
|
|
||||||
|
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||||
|
this.createDom('div', { className: 'banner' },
|
||||||
|
this.createDom('div', { className: 'logo' },
|
||||||
|
"Jasmine",
|
||||||
|
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||||
|
this.createDom('div', { className: 'options' },
|
||||||
|
"Show ",
|
||||||
|
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||||
|
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||||
|
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||||
|
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."));
|
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||||
this.document.body.appendChild(this.runnerDiv);
|
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||||
|
);
|
||||||
|
|
||||||
|
this.document.body.appendChild(this.outerDiv);
|
||||||
|
|
||||||
for (var i = 0; i < suites.length; i++) {
|
for (var i = 0; i < suites.length; i++) {
|
||||||
var suite = suites[i];
|
var suite = suites[i];
|
||||||
|
@ -37,7 +60,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||||
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
this.suiteDivs[suite.getFullName()] = suiteDiv;
|
||||||
var parentDiv = this.document.body;
|
var parentDiv = this.outerDiv;
|
||||||
if (suite.parentSuite) {
|
if (suite.parentSuite) {
|
||||||
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
|
||||||
}
|
}
|
||||||
|
@ -45,6 +68,23 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startedAt = new Date();
|
this.startedAt = new Date();
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
showPassed.onchange = function(evt) {
|
||||||
|
if (evt.target.checked) {
|
||||||
|
self.outerDiv.className += ' show-passed';
|
||||||
|
} else {
|
||||||
|
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
showSkipped.onchange = function(evt) {
|
||||||
|
if (evt.target.checked) {
|
||||||
|
self.outerDiv.className += ' show-skipped';
|
||||||
|
} else {
|
||||||
|
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||||
|
@ -63,6 +103,8 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||||
|
|
||||||
|
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||||
|
@ -82,17 +124,30 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||||
}
|
}
|
||||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName()));
|
this.createDom('a', {
|
||||||
|
className: 'description',
|
||||||
|
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||||
|
title: spec.getFullName()
|
||||||
|
}, spec.description));
|
||||||
|
|
||||||
|
|
||||||
var resultItems = results.getItems();
|
var resultItems = results.getItems();
|
||||||
|
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||||
for (var i = 0; i < resultItems.length; i++) {
|
for (var i = 0; i < resultItems.length; i++) {
|
||||||
var result = resultItems[i];
|
var result = resultItems[i];
|
||||||
if (result.passed && !result.passed()) {
|
if (result.passed && !result.passed()) {
|
||||||
specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||||
specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
||||||
|
if (result.trace.stack) {
|
||||||
|
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messagesDiv.childNodes.length > 0) {
|
||||||
|
specDiv.appendChild(messagesDiv);
|
||||||
|
}
|
||||||
|
|
||||||
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -690,6 +690,18 @@ jasmine.Env.prototype.version = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns string containing jasmine version build info, if set.
|
||||||
|
*/
|
||||||
|
jasmine.Env.prototype.versionString = function() {
|
||||||
|
if (jasmine.version_) {
|
||||||
|
var version = this.version();
|
||||||
|
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
||||||
|
} else {
|
||||||
|
return "version unknown";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a sequential integer starting at 0
|
* @returns a sequential integer starting at 0
|
||||||
*/
|
*/
|
||||||
|
@ -2314,5 +2326,5 @@ jasmine.version_= {
|
||||||
"major": 0,
|
"major": 0,
|
||||||
"minor": 10,
|
"minor": 10,
|
||||||
"build": 2,
|
"build": 2,
|
||||||
"revision": 1268969696
|
"revision": 1270162506
|
||||||
};
|
};
|
||||||
|
|
102
lib/jasmine.css
102
lib/jasmine.css
|
@ -3,8 +3,40 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
body .run_spec {
|
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||||
|
color: #303;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.run_spec {
|
||||||
float:right;
|
float:right;
|
||||||
|
padding-right: 5px;
|
||||||
|
font-size: .8em;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.jasmine_reporter {
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.banner {
|
||||||
|
color: #303;
|
||||||
|
background-color: #fef;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
float: left;
|
||||||
|
font-size: 1.1em;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo .version {
|
||||||
|
font-size: .6em;
|
||||||
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.runner.running {
|
.runner.running {
|
||||||
|
@ -12,24 +44,26 @@ body .run_spec {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.options {
|
||||||
.runner {
|
text-align: right;
|
||||||
border: 1px solid gray;
|
font-size: .8em;
|
||||||
margin: 5px;
|
|
||||||
padding-left: 1em;
|
|
||||||
padding-right: 1em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.suite {
|
.suite {
|
||||||
border: 1px outset gray;
|
border: 1px outset gray;
|
||||||
margin: 5px;
|
margin: 5px 0;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.suite .suite {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.suite.passed {
|
.suite.passed {
|
||||||
background-color: #cfc;
|
background-color: #dfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.suite.failed {
|
.suite.failed {
|
||||||
|
@ -38,22 +72,51 @@ body .run_spec {
|
||||||
|
|
||||||
.spec {
|
.spec {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
padding-left: 1em;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spec.failed, .spec.passed, .spec.skipped {
|
||||||
|
padding-bottom: 5px;
|
||||||
|
border: 1px solid gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spec.failed {
|
||||||
|
background-color: #fbb;
|
||||||
|
border-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spec.passed {
|
||||||
|
background-color: #bfb;
|
||||||
|
border-color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spec.skipped {
|
||||||
|
background-color: #bbb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages {
|
||||||
|
border-left: 1px dashed gray;
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.passed {
|
.passed {
|
||||||
background-color: #cfc;
|
background-color: #cfc;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.failed {
|
.failed {
|
||||||
background-color: #fdd;
|
background-color: #fbb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skipped {
|
.skipped {
|
||||||
color: #777;
|
color: #777;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*.resultMessage {*/
|
/*.resultMessage {*/
|
||||||
/*white-space: pre;*/
|
/*white-space: pre;*/
|
||||||
/*}*/
|
/*}*/
|
||||||
|
@ -72,15 +135,32 @@ body .run_spec {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
height: 5em;
|
max-height: 5em;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border: 1px inset red;
|
border: 1px inset red;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
background: #eef;
|
background: #eef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.finished-at {
|
||||||
|
padding-left: 1em;
|
||||||
|
font-size: .6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-passed .passed,
|
||||||
|
.show-skipped .skipped {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#jasmine_content {
|
#jasmine_content {
|
||||||
position:fixed;
|
position:fixed;
|
||||||
right: 100%;
|
right: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.runner {
|
||||||
|
border: 1px solid gray;
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
|
padding: 2px 0 2px 10px;
|
||||||
|
}
|
||||||
|
|
|
@ -57,6 +57,23 @@ describe("jasmine.Env", function() {
|
||||||
"revision": 8
|
"revision": 8
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("versionString", function() {
|
||||||
|
it("should return a stringified version number", function() {
|
||||||
|
jasmine.version_ = {
|
||||||
|
"major": 1,
|
||||||
|
"minor": 9,
|
||||||
|
"build": 7,
|
||||||
|
"revision": 8
|
||||||
|
};
|
||||||
|
expect(env.versionString()).toEqual("1.9.7 revision 8");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return a nice string when version is unknown", function() {
|
||||||
|
jasmine.version_ = null;
|
||||||
|
expect(env.versionString()).toEqual("version unknown");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow reporters to be registered", function() {
|
it("should allow reporters to be registered", function() {
|
||||||
|
|
|
@ -14,6 +14,20 @@ describe("TrivialReporter", function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findElements(divs, withClass) {
|
||||||
|
var els = [];
|
||||||
|
for (var i = 0; i < divs.length; i++) {
|
||||||
|
if (divs[i].className == withClass) els.push(divs[i]);
|
||||||
|
}
|
||||||
|
return els;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findElement(divs, withClass) {
|
||||||
|
var els = findElements(divs, withClass);
|
||||||
|
if (els.length > 0) return els[0];
|
||||||
|
throw new Error("couldn't find div with class " + withClass);
|
||||||
|
}
|
||||||
|
|
||||||
it("should run only specs beginning with spec parameter", function() {
|
it("should run only specs beginning with spec parameter", function() {
|
||||||
var trivialReporter = new jasmine.TrivialReporter({ location: {search: "?spec=run%20this"} });
|
var trivialReporter = new jasmine.TrivialReporter({ location: {search: "?spec=run%20this"} });
|
||||||
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
||||||
|
@ -24,14 +38,15 @@ describe("TrivialReporter", function() {
|
||||||
it("should display empty divs for every suite when the runner is starting", function() {
|
it("should display empty divs for every suite when the runner is starting", function() {
|
||||||
var trivialReporter = new jasmine.TrivialReporter({ body: body });
|
var trivialReporter = new jasmine.TrivialReporter({ body: body });
|
||||||
trivialReporter.reportRunnerStarting({
|
trivialReporter.reportRunnerStarting({
|
||||||
|
env: new jasmine.Env(),
|
||||||
suites: function() {
|
suites: function() {
|
||||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
var divs = findElements(body.getElementsByTagName("div"), "suite");
|
||||||
expect(divs.length).toEqual(2);
|
expect(divs.length).toEqual(1);
|
||||||
expect(divs[1].innerHTML).toContain("suite 1");
|
expect(divs[0].innerHTML).toContain("suite 1");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Matcher reporting', function () {
|
describe('Matcher reporting', function () {
|
||||||
|
@ -104,6 +119,7 @@ describe("TrivialReporter", function() {
|
||||||
|
|
||||||
trivialReporter = new jasmine.TrivialReporter({ body: body });
|
trivialReporter = new jasmine.TrivialReporter({ body: body });
|
||||||
trivialReporter.reportRunnerStarting({
|
trivialReporter.reportRunnerStarting({
|
||||||
|
env: new jasmine.Env(),
|
||||||
suites: function() {
|
suites: function() {
|
||||||
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
||||||
}
|
}
|
||||||
|
@ -120,10 +136,11 @@ describe("TrivialReporter", function() {
|
||||||
trivialReporter.reportSpecResults(spec);
|
trivialReporter.reportSpecResults(spec);
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
var divs = body.getElementsByTagName("div");
|
||||||
expect(divs[3].innerHTML).toEqual("Expected 'a' to be null, but it was not");
|
var errorDiv = findElement(divs, 'resultMessage fail');
|
||||||
|
expect(errorDiv.innerHTML).toEqual("Expected 'a' to be null, but it was not");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add the failure message to the DOM (non-toEquals matchers)", function() {
|
it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
|
||||||
expectationResult = new jasmine.ExpectationResult({
|
expectationResult = new jasmine.ExpectationResult({
|
||||||
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
|
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
|
||||||
});
|
});
|
||||||
|
@ -133,7 +150,8 @@ describe("TrivialReporter", function() {
|
||||||
trivialReporter.reportSpecResults(spec);
|
trivialReporter.reportSpecResults(spec);
|
||||||
|
|
||||||
var divs = body.getElementsByTagName("div");
|
var divs = body.getElementsByTagName("div");
|
||||||
expect(divs[3].innerHTML).toEqual("Expected '1 < 2' to <b>e null, & it was not");
|
var errorDiv = findElement(divs, 'resultMessage fail');
|
||||||
|
expect(errorDiv.innerHTML).toEqual("Expected '1 < 2' to <b>e null, & it was not");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
12
src/Env.js
12
src/Env.js
|
@ -46,6 +46,18 @@ jasmine.Env.prototype.version = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns string containing jasmine version build info, if set.
|
||||||
|
*/
|
||||||
|
jasmine.Env.prototype.versionString = function() {
|
||||||
|
if (jasmine.version_) {
|
||||||
|
var version = this.version();
|
||||||
|
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
|
||||||
|
} else {
|
||||||
|
return "version unknown";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns a sequential integer starting at 0
|
* @returns a sequential integer starting at 0
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue