Custom matchers fail to behave as expected
If they return false, that should be respected. Submitted via @tjgrathwell [Finish #58184156] close #434
This commit is contained in:
@@ -1781,9 +1781,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
var result = true;
|
||||
|
||||
for (var i = 0; i < customTesters.length; i++) {
|
||||
result = customTesters[i](a, b);
|
||||
if (result) {
|
||||
return true;
|
||||
var customTesterResult = customTesters[i](a, b);
|
||||
if (!j$.util.isUndefined(customTesterResult)) {
|
||||
return customTesterResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,10 +153,22 @@ describe("matchersUtil", function() {
|
||||
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true);
|
||||
});
|
||||
|
||||
it("passes for two empty Objects", function () {
|
||||
expect(j$.matchersUtil.equals({}, {})).toBe(true);
|
||||
});
|
||||
|
||||
describe("when a custom equality matcher is installed that returns 'undefined'", function () {
|
||||
var tester = function(a, b) { return jasmine.undefined; };
|
||||
|
||||
it("passes for two empty Objects", function () {
|
||||
expect(j$.matchersUtil.equals({}, {}, [tester])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it("fails for equivalents when a custom equality matcher returns false", function() {
|
||||
var tester = function(a, b) { return false; };
|
||||
|
||||
expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(false);
|
||||
expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
var result = true;
|
||||
|
||||
for (var i = 0; i < customTesters.length; i++) {
|
||||
result = customTesters[i](a, b);
|
||||
if (result) {
|
||||
return true;
|
||||
var customTesterResult = customTesters[i](a, b);
|
||||
if (!j$.util.isUndefined(customTesterResult)) {
|
||||
return customTesterResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,4 +176,4 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
return typeof obj === 'function';
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user