forked from elliotf/mocha-sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mocha-sinon.js
52 lines (43 loc) · 1.05 KB
/
mocha-sinon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(function(){
function mochaSinon(sinon){
if (typeof beforeEach !== "function") {
throw "mocha-sinon relies on mocha having been loaded.";
}
beforeEach(function() {
if (null == this.sinon) {
this.sinon = sinon.sandbox.create();
}
});
before(function() {
if (null == this.sinon) {
this.sinon = sinon.sandbox.create();
}
});
afterEach(function() {
if (this.sinon && 'function' === typeof this.sinon.restore) {
this.sinon.restore();
}
});
after(function() {
if (this.sinon && 'function' === typeof this.sinon.restore) {
this.sinon.restore();
}
});
}
(function(plugin){
if (
typeof window === "object"
&& typeof window.sinon === "object"
) {
plugin(window.sinon);
} else if (typeof require === "function") {
var sinon = require('sinon');
module.exports = function () {
plugin(sinon);
};
plugin(sinon);
} else {
throw "We could not find sinon through a supported module loading technique. Pull requests are welcome!";
}
})(mochaSinon);
})();