buildExpectationResult now returns a data object.
- Meant for passing to reporters.
This commit is contained in:
@@ -450,7 +450,7 @@ jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
} else if (result.type == 'expect' && !result.passed) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
@@ -465,7 +465,8 @@ jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
|
||||
jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
@@ -615,7 +616,7 @@ jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
var status = results.passed ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
@@ -635,7 +636,7 @@ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
} else if (result.type == 'expect' && !result.passed) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
|
||||
@@ -509,24 +509,18 @@ jasmine.util.extend = function(destination, source) {
|
||||
};
|
||||
|
||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
jasmine.ExpectationResult = function(params) {
|
||||
var self = this;
|
||||
jasmine.buildExpectationResult = function(params) {
|
||||
var trace = (params.trace || new Error(this.message));
|
||||
var message = params.passed ? 'Passed.' : params.message;
|
||||
return jasmine.util.extend(self, {
|
||||
return {
|
||||
type: 'expect',
|
||||
matcherName: params.matcherName,
|
||||
expected: params.expected,
|
||||
actual: params.actual,
|
||||
message: message,
|
||||
trace: params.passed ? '' : trace,
|
||||
toString: function() {
|
||||
return message;
|
||||
},
|
||||
passed: function() {
|
||||
return params.passed;
|
||||
}
|
||||
});
|
||||
passed: params.passed
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Environment for Jasmine
|
||||
@@ -918,7 +912,7 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||
type: isSuite ? 'suite' : 'spec',
|
||||
children: []
|
||||
};
|
||||
|
||||
|
||||
if (isSuite) {
|
||||
var children = suiteOrSpec.children();
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
@@ -973,11 +967,12 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||
var resultMessage = result.messages[messageIndex];
|
||||
summaryMessages.push({
|
||||
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
|
||||
passed: resultMessage.passed ? resultMessage.passed() : true,
|
||||
//TODO: wat? in theory this is saying non-expect results should always be considered passed, but that's weird.
|
||||
passed: resultMessage.passed || true,
|
||||
type: resultMessage.type,
|
||||
message: resultMessage.message,
|
||||
trace: {
|
||||
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
|
||||
stack: !resultMessage.passed ? resultMessage.trace.stack : jasmine.undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1050,7 +1045,7 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
||||
message += ".";
|
||||
}
|
||||
}
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
var expectationResult = jasmine.buildExpectationResult({
|
||||
matcherName: matcherName,
|
||||
passed: result,
|
||||
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
|
||||
@@ -1668,13 +1663,14 @@ jasmine.NestedResults.prototype.getItems = function() {
|
||||
* Adds a result, tracking counts (total, passed, & failed)
|
||||
* @param {jasmine.ExpectationResult|jasmine.NestedResults} result
|
||||
*/
|
||||
//TODO: Results are meant for consumption by reporters, not internally.
|
||||
jasmine.NestedResults.prototype.addResult = function(result) {
|
||||
if (result.type != 'log') {
|
||||
if (result.items_) {
|
||||
this.rollupCounts(result);
|
||||
} else {
|
||||
this.totalCount++;
|
||||
if (result.passed()) {
|
||||
if (result.passed) {
|
||||
this.passedCount++;
|
||||
} else {
|
||||
this.failedCount++;
|
||||
@@ -2135,7 +2131,7 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag
|
||||
};
|
||||
|
||||
jasmine.Spec.prototype.fail = function (e) {
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
var expectationResult = jasmine.buildExpectationResult({
|
||||
passed: false,
|
||||
message: e ? jasmine.util.formatException(e) : 'Exception',
|
||||
trace: { stack: e.stack }
|
||||
|
||||
Reference in New Issue
Block a user