buildExpectationResult now returns a data object.
- Meant for passing to reporters.
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user