Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

Commit

Permalink
Fix html escaping of matcher failure messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
xian committed Nov 12, 2009
1 parent 5a8a050 commit ee5905d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/TrivialReporter.js
Expand Up @@ -89,9 +89,7 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
for (var i = 0; i < resultItems.length; i++) {
var result = resultItems[i];
if (result.passed && !result.passed()) {
var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'});
resultMessageDiv.innerHTML = result.message; // todo: lame; mend
specDiv.appendChild(resultMessageDiv);
specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
}
}
Expand Down
13 changes: 13 additions & 0 deletions spec/suites/TrivialReporterSpec.js
Expand Up @@ -122,6 +122,19 @@ describe("TrivialReporter", function() {
var divs = body.getElementsByTagName("div");
expect(divs[3].innerHTML).toEqual("Expected 'a' to be null, but it was not");
});

it("should add the failure message to the DOM (non-toEquals matchers)", function() {
expectationResult = new jasmine.ExpectationResult({
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
});

spyOn(results, 'getItems').andReturn([expectationResult]);

trivialReporter.reportSpecResults(spec);

var divs = body.getElementsByTagName("div");
expect(divs[3].innerHTML).toEqual("Expected '1 &lt; 2' to &lt;b&gt;e null, &amp; it was not");
});
});

});

0 comments on commit ee5905d

Please sign in to comment.