Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sinon-chai to use latest versions of chai and sinon #162

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"env": {
"node": true,
"amd": true,
"es6": false
"es6": true
},
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
// Possible errors
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.js → .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";

module.exports = {
require: ["./test/common"]
require: ["./test/common.js"]
};
59 changes: 29 additions & 30 deletions lib/sinon-chai.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,5 @@
"use strict";
/* eslint-disable no-invalid-this */

(function (sinonChai) {
// Module systems magic dance.

/* istanbul ignore else */
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// NodeJS
module.exports = sinonChai;
} else if (typeof define === "function" && define.amd) {
// AMD
define(function () {
return sinonChai;
});
} else {
// Other environment (usually <script> tag): plug in to global chai instance directly.
/* global chai: false */
chai.use(sinonChai);
}
}(function (chai, utils) {
function sinonChai(chai, utils) {
var slice = Array.prototype.slice;

function isSpy(putativeSpy) {
Expand Down Expand Up @@ -128,22 +109,40 @@
utils.flag(this, "always", true);
});

sinonProperty("called", "been called", " at least once, but it was never called");
sinonPropertyAsBooleanMethod("callCount", "been called exactly %1", ", but it was called %c%C");
sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
// "expected %n to have been called at least once but was never called",
sinonProperty("called", "been called at least once", ", but it was never called");
// ??
sinonPropertyAsBooleanMethod("callCount", "been called %1", " but it was called %c%C");
// "expected %n to be called once but was called %c%C",
sinonProperty("calledOnce", "been called once", " but it was called %c%C");
// "expected %n to be called twice but was called %c%C",
sinonProperty("calledTwice", "been called twice", " but it was called %c%C");
// "expected %n to be called thrice but was called %c%C",
sinonProperty("calledThrice", "been called thrice", " but it was called %c%C");
// "expected %n to be called with new"
sinonMethodAsProperty("calledWithNew", "been called with new");
// ??
sinonMethod("calledBefore", "been called before %1");
// ??
sinonMethod("calledAfter", "been called after %1");
// ??
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");
// "expected %n to be called with %1 as this but was called with %t",
sinonMethod("calledOn", "been called with %1 as this", " but it was called with %t");
// "expected %n to be called with arguments %D",
sinonMethod("calledWith", "been called with arguments %*", "%D");
sinonMethod("calledOnceWith", "been called exactly once with arguments %*", "%D");
// ??
sinonMethod("calledOnceWith", "been called once with arguments %*", "%D");
// "expected %n to be called with exact arguments %D",
sinonMethod("calledWithExactly", "been called with exact arguments %*", "%D");
sinonMethod("calledOnceWithExactly", "been called exactly once with exact arguments %*", "%D");
sinonMethod("calledWithMatch", "been called with arguments matching %*", "%D");
// "expected %n to be called once and with exact arguments %D",
sinonMethod("calledOnceWithExactly", "been called once and with exact arguments %*", "%D");
// "expected %n to be called with match %D",
sinonMethod("calledWithMatch", "been called with match %*", "%D");
sinonMethod("returned", "returned %1");
exceptionalSinonMethod("thrown", "threw", "thrown %1");
}));
}

export default sinonChai;
Loading