Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pass through custom equality testers in toHaveBeenCalledWith [fixes #536

]
  • Loading branch information...
commit 00c8e372576438243a8f977b8bc7b81f04389dd6 1 parent e53b487
@sheelc sheelc authored
View
4 lib/jasmine-core/jasmine.js
@@ -2257,7 +2257,7 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
- function toHaveBeenCalledWith(util) {
+ function toHaveBeenCalledWith(util, customEqualityTesters) {
return {
compare: function() {
var args = Array.prototype.slice.call(arguments, 0),
@@ -2274,7 +2274,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
return result;
}
- if (util.contains(actual.calls.allArgs(), expectedArgs)) {
+ if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
result.pass = true;
result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
} else {
View
14 spec/core/matchers/toHaveBeenCalledWithSpec.js
@@ -14,6 +14,20 @@ describe("toHaveBeenCalledWith", function() {
expect(result.message()).toEqual("Expected spy called-spy not to have been called with [ 'a', 'b' ] but it was.");
});
+ it("passes through the custom equality testers", function() {
+ var util = {
+ contains: jasmine.createSpy('delegated-contains').and.returnValue(true)
+ },
+ customEqualityTesters = [function() { return true; }],
+ matcher = j$.matchers.toHaveBeenCalledWith(util, customEqualityTesters),
+ calledSpy = j$.createSpy('called-spy');
+
+ calledSpy('a', 'b');
+ matcher.compare(calledSpy, 'a', 'b');
+
+ expect(util.contains).toHaveBeenCalledWith([['a', 'b']], ['a', 'b'], customEqualityTesters);
+ });
+
it("fails when the actual was not called", function() {
var util = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(false)
View
4 src/core/matchers/toHaveBeenCalledWith.js
@@ -1,6 +1,6 @@
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
- function toHaveBeenCalledWith(util) {
+ function toHaveBeenCalledWith(util, customEqualityTesters) {
return {
compare: function() {
var args = Array.prototype.slice.call(arguments, 0),
@@ -17,7 +17,7 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
return result;
}
- if (util.contains(actual.calls.allArgs(), expectedArgs)) {
+ if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
result.pass = true;
result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.