buildExpectationResult now returns a data object.
- Meant for passing to reporters.
This commit is contained in:
@@ -174,4 +174,4 @@ jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
|
||||
summaryFunction(runner.specs().length, results.failedCount);
|
||||
doneCallback(runner);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
jasmine.ExpectationResult = function(params) {
|
||||
var self = this;
|
||||
var trace = (params.trace || new Error(this.message));
|
||||
var message = params.passed ? 'Passed.' : params.message;
|
||||
return jasmine.util.extend(self, {
|
||||
jasmine.buildExpectationResult = function(params) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
message: params.passed ? 'Passed.' : params.message,
|
||||
trace: params.passed ? '' : (params.trace || new Error(this.message)),
|
||||
passed: params.passed
|
||||
};
|
||||
};
|
||||
|
||||
@@ -30,7 +30,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++) {
|
||||
@@ -85,11 +85,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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,7 +60,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],
|
||||
|
||||
@@ -56,13 +56,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++;
|
||||
|
||||
@@ -118,7 +118,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 }
|
||||
|
||||
@@ -61,7 +61,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) {
|
||||
@@ -76,4 +76,4 @@ jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);
|
||||
|
||||
@@ -126,7 +126,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';
|
||||
}
|
||||
@@ -146,7 +146,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) {
|
||||
|
||||
Reference in New Issue
Block a user