- It causes memory problems in phantom and you probably don't need it anyways. Fixes #640 Fixes #690
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
//TODO: expectation result may make more sense as a presentation of an expectation.
|
|
getJasmineRequireObj().buildExpectationResult = function() {
|
|
function buildExpectationResult(options) {
|
|
var messageFormatter = options.messageFormatter || function() {},
|
|
stackFormatter = options.stackFormatter || function() {};
|
|
|
|
var result = {
|
|
matcherName: options.matcherName,
|
|
message: message(),
|
|
stack: stack(),
|
|
passed: options.passed
|
|
};
|
|
|
|
if(!result.passed) {
|
|
result.expected = options.expected;
|
|
result.actual = options.actual;
|
|
}
|
|
|
|
return result;
|
|
|
|
function message() {
|
|
if (options.passed) {
|
|
return 'Passed.';
|
|
} else if (options.message) {
|
|
return options.message;
|
|
} else if (options.error) {
|
|
return messageFormatter(options.error);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function stack() {
|
|
if (options.passed) {
|
|
return '';
|
|
}
|
|
|
|
var error = options.error;
|
|
if (!error) {
|
|
try {
|
|
throw new Error(message());
|
|
} catch (e) {
|
|
error = e;
|
|
}
|
|
}
|
|
return stackFormatter(error);
|
|
}
|
|
}
|
|
|
|
return buildExpectationResult;
|
|
};
|