Skip to content

Commit

Permalink
Inline timesWithWords.
Browse files Browse the repository at this point in the history
It's a bit unfortunate that we're duplicating code from Sinon itself, but the only other way I can think to make this work is by adding a hard dependency on Sinon (e.g. `require("sinon")`), which is annoying given our UMD wrapper.
  • Loading branch information
domenic committed Jan 25, 2014
1 parent d86c005 commit 5aeb083
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/sinon-chai.js
Expand Up @@ -26,6 +26,13 @@
typeof putativeSpy.calledWithExactly === "function";
}

function timesInWords(count) {
return count === 1 ? "once" :
count === 2 ? "twice" :
count === 3 ? "thrice" :
(count || 0) + " times";
}

function isCall(putativeCall) {
return putativeCall && isSpy(putativeCall.proxy);
}
Expand Down Expand Up @@ -66,7 +73,7 @@
utils.addMethod(chai.Assertion.prototype, name, function (arg) {
assertCanWorkWith(this);

var messages = getMessages(this._obj, action, nonNegatedSuffix, false, [sinon.timesInWords(arg)]);
var messages = getMessages(this._obj, action, nonNegatedSuffix, false, [timesInWords(arg)]);
this.assert(this._obj[name] === arg, messages.affirmative, messages.negative);
});
}
Expand Down

0 comments on commit 5aeb083

Please sign in to comment.