Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mocha-sinon

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-sinon - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

18

mocha-sinon.js

@@ -11,22 +11,6 @@ (function(){

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) {
} else {
this.sinon.restore();
}
});
after(function() {
if (this.sinon && 'function' === typeof this.sinon.restore) {
this.sinon.restore();
}
});
}

@@ -33,0 +17,0 @@

10

package.json
{
"name": "mocha-sinon",
"version": "1.2.0",
"version": "2.0.0",
"keywords": [
"mocha",
"sinon",
"spies"
"spies",
"testing",
"pollution"
],

@@ -24,5 +26,5 @@ "description": "mocha integration for sinon",

"mocha-phantomjs": "*",
"nodemon": "*",
"phantomjs-prebuilt": "*",
"sinon": "*",
"sinon-chai": "*"
"sinon": "*"
},

@@ -29,0 +31,0 @@ "engines": {

@@ -88,11 +88,11 @@ mocha-sinon

```javascript
var sinon = require('sinon');
// require sinon somehow and in your test helper, do:
beforeEach(function() {
this.sinon = sinon.sandbox.create();
if (null == this.sinon) {
this.sinon = sinon.sandbox.create();
} else {
this.sinon.restore();
}
});
afterEach(function(){
this.sinon.restore();
});
```

@@ -12,3 +12,2 @@ ((function(test){

chai.use(require('sinon-chai'));
test(chai, subject);

@@ -19,15 +18,18 @@

// Other environment (usually <script> tag): plug in to global chai instance directly.
test(chai, false);
test(chai);
}
})(function(chai, subject){
})(function(chai){
var expect;
var expect = chai.expect;
var someGlobal = {};
someGlobal.someFunction = function() {
return "someGlobal's function";
// Purposefully leaky fixture data, to be able to test mocha-sinon's cleanup
// Normally you want to set your fixture data in a beforeEach
var someGlobal = {
someFunction: function() {
return "someGlobal's function";
},
};
var someGlobalFunction = function() {
return "someGlobalFunction";
};
beforeEach(function() {
expect = chai.expect;
});

@@ -45,40 +47,6 @@ describe("mocha-sinon", function() {

it("cleans up spies after each spec", function() {
it("automatically cleans up spies after each spec", function() {
expect(someGlobal.someFunction()).to.equal("someGlobal's function");
});
});
if (subject) {
(function() {
var sinon = require('sinon');
describe("mocha-sinon on the backend", function() {
var sandbox;
beforeEach(function() {
sandbox = sinon.sandbox.create();
});
afterEach(function(){
sandbox.restore();
});
it("exports a function to register beforeEach/afterEach", function() {
sandbox.spy(global, 'beforeEach');
sandbox.spy(global, 'afterEach');
sandbox.spy(global, 'before');
sandbox.spy(global, 'after');
expect(subject).to.be.a('function');
subject();
expect(global.beforeEach).to.have.been.called;
expect(global.afterEach).to.have.been.called;
expect(global.before).to.have.been.called;
expect(global.after).to.have.been.called;
});
});
})();
}
}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc