Skip to content

Commit

Permalink
Fix mock.withArgs using matchers (sinonjs#1961)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni authored and Franck Romano committed Oct 1, 2019
1 parent 0fe19dc commit 1accb3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sinon/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function arrayEquals(arr1, arr2, compareLength) {
}

return every(arr1, function(element, i) {
return deepEqual(element, arr2[i]);
return deepEqual(arr2[i], element);
});
}

Expand Down
14 changes: 14 additions & 0 deletions test/mock-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,20 @@ describe("sinonMock", function() {
{ name: "ExpectationError" }
);
});

it("should not throw when expectation withArgs using matcher", function() {
var obj = {
foobar: function() {
return;
}
};
var mock = sinonMock(obj);
mock.expects("foobar").withArgs(match.string);

refute.exception(function() {
obj.foobar("arg1");
});
});
});

describe(".withExactArgs", function() {
Expand Down

0 comments on commit 1accb3a

Please sign in to comment.