Skip to content

Commit

Permalink
Add improved diffing for calledWith and friends
Browse files Browse the repository at this point in the history
Closes #104. Follows sinonjs/sinon#1203 mostly, although we still include the %* arguments list, as doing otherwise is a bit tricky for the negated case.
  • Loading branch information
BuiltByWalsh authored and domenic committed Jul 18, 2017
1 parent 1513007 commit 48d2408
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/sinon-chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@
sinonMethod("calledImmediatelyBefore", "been called immediately before %1");
sinonMethod("calledImmediatelyAfter", "been called immediately after %1");
sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
sinonMethod("calledWith", "been called with arguments %*", "%C");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
sinonMethod("calledWith", "been called with arguments %*", "%D");
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%D");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%D");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));
12 changes: 6 additions & 6 deletions test/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,23 @@ describe("Messages", function () {

expect(function () {
spy.should.have.been.calledWith("a", "b", "c");
}).to.throw("expected spy to have been called with arguments a, b, c\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with arguments a, b, c");
expect(function () {
spy.should.have.been.calledWithExactly("a", "b", "c");
}).to.throw("expected spy to have been called with exact arguments a, b, c\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with exact arguments a, b, c");
expect(function () {
spy.should.have.been.calledWithMatch(sinon.match("foo"));
}).to.throw("expected spy to have been called with arguments matching match(\"foo\")\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with arguments matching match(\"foo\")");

expect(function () {
spy.getCall(0).should.have.been.calledWith("a", "b", "c");
}).to.throw("expected spy to have been called with arguments a, b, c\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with arguments a, b, c");
expect(function () {
spy.getCall(0).should.have.been.calledWithExactly("a", "b", "c");
}).to.throw("expected spy to have been called with exact arguments a, b, c\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with exact arguments a, b, c");
expect(function () {
spy.getCall(0).should.have.been.calledWithMatch(sinon.match("foo"));
}).to.throw("expected spy to have been called with arguments matching match(\"foo\")\n spy(1, 2, 3)");
}).to.throw("expected spy to have been called with arguments matching match(\"foo\")");
});

it("should be correct for the negated cases", function () {
Expand Down

0 comments on commit 48d2408

Please sign in to comment.