@@ -70,7 +70,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
|||||||
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
||||||
j$.Expector = jRequire.Expector(j$);
|
j$.Expector = jRequire.Expector(j$);
|
||||||
j$.Expectation = jRequire.Expectation(j$);
|
j$.Expectation = jRequire.Expectation(j$);
|
||||||
j$.buildExpectationResult = jRequire.buildExpectationResult();
|
j$.buildExpectationResult = jRequire.buildExpectationResult(j$);
|
||||||
j$.noopTimer = jRequire.noopTimer();
|
j$.noopTimer = jRequire.noopTimer();
|
||||||
j$.JsApiReporter = jRequire.JsApiReporter(j$);
|
j$.JsApiReporter = jRequire.JsApiReporter(j$);
|
||||||
j$.matchersUtil = jRequire.matchersUtil(j$);
|
j$.matchersUtil = jRequire.matchersUtil(j$);
|
||||||
@@ -3531,7 +3531,7 @@ getJasmineRequireObj().ExpectationFilterChain = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||||
getJasmineRequireObj().buildExpectationResult = function() {
|
getJasmineRequireObj().buildExpectationResult = function(j$) {
|
||||||
function buildExpectationResult(options) {
|
function buildExpectationResult(options) {
|
||||||
var messageFormatter = options.messageFormatter || function() {},
|
var messageFormatter = options.messageFormatter || function() {},
|
||||||
stackFormatter = options.stackFormatter || function() {};
|
stackFormatter = options.stackFormatter || function() {};
|
||||||
@@ -3555,6 +3555,22 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
|||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
result.expected = options.expected;
|
result.expected = options.expected;
|
||||||
result.actual = options.actual;
|
result.actual = options.actual;
|
||||||
|
|
||||||
|
if (options.error && !j$.isString_(options.error)) {
|
||||||
|
if ('code' in options.error) {
|
||||||
|
result.code = options.error.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
options.error.code === 'ERR_ASSERTION' &&
|
||||||
|
options.expected === '' &&
|
||||||
|
options.actual === ''
|
||||||
|
) {
|
||||||
|
result.expected = options.error.expected;
|
||||||
|
result.actual = options.error.actual;
|
||||||
|
result.matcherName = 'assert ' + options.error.operator;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -90,4 +90,37 @@ describe('buildExpectationResult', function() {
|
|||||||
});
|
});
|
||||||
expect(result.actual).toBe('some-value');
|
expect(result.actual).toBe('some-value');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles nodejs assertions', function() {
|
||||||
|
if (typeof require === 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var assert = require('assert');
|
||||||
|
var error;
|
||||||
|
var value = 8421;
|
||||||
|
var expectedValue = 'JasmineExpectationTestValue';
|
||||||
|
try {
|
||||||
|
assert.equal(value, expectedValue);
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.code).toEqual('ERR_ASSERTION');
|
||||||
|
expect(error.actual).toEqual(value);
|
||||||
|
expect(error.expected).toEqual(expectedValue);
|
||||||
|
expect(error.operator).toEqual('==');
|
||||||
|
|
||||||
|
var result = jasmineUnderTest.buildExpectationResult({
|
||||||
|
passed: false,
|
||||||
|
matcherName: '',
|
||||||
|
expected: '',
|
||||||
|
actual: '',
|
||||||
|
error: error
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.code).toEqual('ERR_ASSERTION');
|
||||||
|
expect(result.actual).toEqual(value);
|
||||||
|
expect(result.expected).toEqual(expectedValue);
|
||||||
|
expect(result.matcherName).toEqual('assert ==');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||||
getJasmineRequireObj().buildExpectationResult = function() {
|
getJasmineRequireObj().buildExpectationResult = function(j$) {
|
||||||
function buildExpectationResult(options) {
|
function buildExpectationResult(options) {
|
||||||
var messageFormatter = options.messageFormatter || function() {},
|
var messageFormatter = options.messageFormatter || function() {},
|
||||||
stackFormatter = options.stackFormatter || function() {};
|
stackFormatter = options.stackFormatter || function() {};
|
||||||
@@ -23,6 +23,22 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
|||||||
if (!result.passed) {
|
if (!result.passed) {
|
||||||
result.expected = options.expected;
|
result.expected = options.expected;
|
||||||
result.actual = options.actual;
|
result.actual = options.actual;
|
||||||
|
|
||||||
|
if (options.error && !j$.isString_(options.error)) {
|
||||||
|
if ('code' in options.error) {
|
||||||
|
result.code = options.error.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
options.error.code === 'ERR_ASSERTION' &&
|
||||||
|
options.expected === '' &&
|
||||||
|
options.actual === ''
|
||||||
|
) {
|
||||||
|
result.expected = options.error.expected;
|
||||||
|
result.actual = options.error.actual;
|
||||||
|
result.matcherName = 'assert ' + options.error.operator;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
|
|||||||
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
|
||||||
j$.Expector = jRequire.Expector(j$);
|
j$.Expector = jRequire.Expector(j$);
|
||||||
j$.Expectation = jRequire.Expectation(j$);
|
j$.Expectation = jRequire.Expectation(j$);
|
||||||
j$.buildExpectationResult = jRequire.buildExpectationResult();
|
j$.buildExpectationResult = jRequire.buildExpectationResult(j$);
|
||||||
j$.noopTimer = jRequire.noopTimer();
|
j$.noopTimer = jRequire.noopTimer();
|
||||||
j$.JsApiReporter = jRequire.JsApiReporter(j$);
|
j$.JsApiReporter = jRequire.JsApiReporter(j$);
|
||||||
j$.matchersUtil = jRequire.matchersUtil(j$);
|
j$.matchersUtil = jRequire.matchersUtil(j$);
|
||||||
|
|||||||
Reference in New Issue
Block a user