Socket
Socket
Sign inDemoInstall

sinon

Package Overview
Dependencies
Maintainers
2
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

3

Changelog.txt

@@ -1,4 +0,1 @@

== 1.3.3 / 2012-04-14
* Fix bug with buster-format
== 1.3.2 / 2012-03-11

@@ -5,0 +2,0 @@ * Stronger Node inference in sandbox

@@ -122,5 +122,2 @@ /*jslint eqeqeq: false, onevar: false, forin: true, nomen: false, regexp: false, plusplus: false*/

deepEqual: function deepEqual(a, b) {
if (sinon.match.isMatcher(a)) {
return a.test(b);
}
if (typeof a != "object" || typeof b != "object") {

@@ -277,10 +274,2 @@ return a === b;

}, 0);
},
typeOf: function (value) {
if (value === null) {
return "null";
}
var string = Object.prototype.toString.call(value);
return string.substring(8, string.length - 1).toLowerCase();
}

@@ -305,3 +294,2 @@ };

module.exports.assert = require("./sinon/assert");
module.exports.match = require("./sinon/match");
}

@@ -308,0 +296,0 @@

@@ -109,14 +109,3 @@ /**

}
if (!property && !!object && typeof object == "object") {
var stubbedObj = sinon.stub.apply(sinon, arguments);
for (var prop in stubbedObj) {
if (typeof stubbedObj[prop] === "function") {
this.add(stubbedObj[prop]);
}
}
return stubbedObj;
}
return this.add(sinon.stub.apply(sinon, arguments));

@@ -123,0 +112,0 @@ },

9

lib/sinon/spy.js

@@ -1,5 +0,2 @@

/**
* @depend ../sinon.js
* @depend match.js
*/
/* @depend ../sinon.js */
/*jslint eqeqeq: false, onevar: false, plusplus: false*/

@@ -37,3 +34,3 @@ /*global module, require, sinon*/

if (!object && !property) {
if (!object || !property) {
return spy.create(function () {});

@@ -396,3 +393,3 @@ }

returned: function returned(value) {
return sinon.deepEqual(value, this.returnValue);
return this.returnValue === value;
},

@@ -399,0 +396,0 @@

@@ -44,4 +44,3 @@ /*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/

func: args[0],
callAt: this.now + delay,
invokeArgs: Array.prototype.slice.call(args, 2)
callAt: this.now + delay
};

@@ -180,4 +179,3 @@

interval: this.timeouts[id].interval,
id: this.timeouts[id].id,
invokeArgs: this.timeouts[id].invokeArgs
id: this.timeouts[id].id
};

@@ -192,11 +190,5 @@ }

callTimer: function (timer) {
if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
try {
if (typeof timer.func == "function") {
timer.func.apply(null, timer.invokeArgs);
timer.func.call(null);
} else {

@@ -216,2 +208,8 @@ eval(timer.func);

if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
if (exception) {

@@ -218,0 +216,0 @@ throw exception;

{
"name": "sinon",
"description": "JavaScript test spies, stubs and mocks.",
"version": "1.3.3",
"version": "1.3.4",
"homepage": "http://cjohansen.no/sinon/",

@@ -6,0 +6,0 @@ "author": "Christian Johansen",

/**
* Sinon.JS 1.3.3, 2012/04/14
* Sinon.JS 1.3.3, 2012/04/16
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
* All rights reserved.

@@ -11,0 +10,0 @@ *

/**
* Sinon.JS 1.3.3, 2012/04/14
* Sinon.JS 1.3.3, 2012/04/16
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
* All rights reserved.

@@ -11,0 +10,0 @@ *

/**
* Sinon.JS 1.3.3, 2012/04/14
* Sinon.JS 1.3.3, 2012/04/16
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
* All rights reserved.

@@ -825,4 +824,3 @@ *

func: args[0],
callAt: this.now + delay,
invokeArgs: Array.prototype.slice.call(args, 2)
callAt: this.now + delay
};

@@ -961,4 +959,3 @@

interval: this.timeouts[id].interval,
id: this.timeouts[id].id,
invokeArgs: this.timeouts[id].invokeArgs
id: this.timeouts[id].id
};

@@ -973,11 +970,5 @@ }

callTimer: function (timer) {
if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
try {
if (typeof timer.func == "function") {
timer.func.apply(null, timer.invokeArgs);
timer.func.call(null);
} else {

@@ -997,2 +988,8 @@ eval(timer.func);

if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
if (exception) {

@@ -999,0 +996,0 @@ throw exception;

/**
* Sinon.JS 1.3.3, 2012/04/14
* Sinon.JS 1.3.3, 2012/04/16
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
* All rights reserved.

@@ -79,4 +78,3 @@ *

func: args[0],
callAt: this.now + delay,
invokeArgs: Array.prototype.slice.call(args, 2)
callAt: this.now + delay
};

@@ -215,4 +213,3 @@

interval: this.timeouts[id].interval,
id: this.timeouts[id].id,
invokeArgs: this.timeouts[id].invokeArgs
id: this.timeouts[id].id
};

@@ -227,11 +224,5 @@ }

callTimer: function (timer) {
if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
try {
if (typeof timer.func == "function") {
timer.func.apply(null, timer.invokeArgs);
timer.func.call(null);
} else {

@@ -251,2 +242,8 @@ eval(timer.func);

if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
if (exception) {

@@ -253,0 +250,0 @@ throw exception;

/**
* Sinon.JS 1.3.3, 2012/04/14
* Sinon.JS 1.3.3, 2012/04/16
*
* @author Christian Johansen (christian@cjohansen.no)
* @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS
*
* (The BSD License)
*
* Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no
* Copyright (c) 2010-2011, Christian Johansen, christian@cjohansen.no
* All rights reserved.

@@ -11,0 +10,0 @@ *

@@ -5,3 +5,3 @@ # Sinon.JS

## Installation
## Installation

@@ -12,3 +12,3 @@ via [npm (node package manager)](http://github.com/isaacs/npm)

or install via git by cloning the repository and including sinon.js
or install via git by cloning the repository and including sinon.js
in your project, as you would any other third party library.

@@ -32,28 +32,8 @@

## Develop?
## Develop?
Check out [todo.org](http://github.com/cjohansen/Sinon.JS/raw/1.0.0/todo.org) in the project repository
## Run the tests
## Running tests on Rhino
### On Node
$ node test/node/run.js
### In the browser, via JsTestDriver
* Install [Node.js](http://nodejs.org/) & [NPM](http://npmjs.org/)
* `$ npm install buster-format`
* Install Java
* Download [jsTestDriver](http://code.google.com/p/js-test-driver/)
* Start the JsTestDriver server
`$ java -jar JsTestDriver.jar --port 4224`
* Open a browser, go to [http://localhost:4224/](http://localhost:4224) and click 'Capture this Browser'
* run the tests
`$ java -jar JsTestDriver.jar --tests all --reset`
### On Rhino
I've added a rudimentary setup for running the tests on Rhino with env.js (as

@@ -60,0 +40,0 @@ this is a fairly common test setup, Sinon should support it). The files are

@@ -14,2 +14,1 @@ global.jstestdriver = { console: console };

require("../sinon/test_case_test.js");
require("../sinon/match_test.js");

@@ -16,3 +16,2 @@ var jstestdriver = {};

load("lib/sinon/test.js");
load("lib/sinon/match.js");
load("lib/sinon/util/fake_server.js");

@@ -33,3 +32,2 @@ load("lib/sinon/util/fake_server_with_clock.js");

load("test/sinon/test_test.js");
load("test/sinon/match_test.js");
load("test/sinon/util/fake_server_test.js");

@@ -36,0 +34,0 @@ load("test/sinon/util/fake_server_with_clock_test.js");

@@ -408,44 +408,2 @@ /*jslint onevar: false, eqeqeq: false*/

});
testCase("TypeOfTest", {
"should return boolean": function () {
assertEquals("boolean", sinon.typeOf(false));
},
"should return string": function () {
assertEquals("string", sinon.typeOf("Sinon.JS"));
},
"should return number": function () {
assertEquals("number", sinon.typeOf(123));
},
"should return object": function () {
assertEquals("object", sinon.typeOf({}));
},
"should return function": function () {
assertEquals("function", sinon.typeOf(function () {}));
},
"should return undefined": function () {
assertEquals("undefined", sinon.typeOf(undefined));
},
"should return null": function () {
assertEquals("null", sinon.typeOf(null));
},
"should return array": function () {
assertEquals("array", sinon.typeOf([]));
},
"should return regexp": function () {
assertEquals("regexp", sinon.typeOf(/.*/));
},
"should return date": function () {
assertEquals("date", sinon.typeOf(new Date()));
}
});
}());

@@ -1031,65 +1031,2 @@ /*jslint onevar: false*/

"assert.calledWith match.any exception message": function () {
this.obj.doSomething(true, true);
assertEquals("expected doSomething to be called with arguments " +
"any, false\n doSomething(true, true)",
this.message("calledWith", this.obj.doSomething,
sinon.match.any, false));
},
"assert.calledWith match.same exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"same(1)\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.same(1)));
},
"assert.calledWith match.typeOf exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"typeOf(\"string\")\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.typeOf("string")));
},
"assert.calledWith match.instanceOf exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"instanceOf(CustomType)\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.instanceOf(function CustomType() {})));
},
"assert.calledWith match.like object exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"like(some: value, and: 123)\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.like({ some: "value", and: 123 })));
},
"assert.calledWith match.like string exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"like(\"Sinon\")\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.like("Sinon")));
},
"assert.calledWith match.like regexp exception message": function () {
this.obj.doSomething();
assertEquals("expected doSomething to be called with arguments " +
"like(/[a-z]+/)\n doSomething()",
this.message("calledWith", this.obj.doSomething,
sinon.match.like(/[a-z]+/)));
},
"assert.alwaysCalledWith exception message": function () {

@@ -1096,0 +1033,0 @@ this.obj.doSomething(1, 3, "hey");

@@ -87,38 +87,3 @@ /*jslint onevar: false, eqeqeq: false, plusplus: false*/

assertEquals(objects, this.collection.fakes);
},
"should add all object methods to fake array": function() {
var object = { method: function () {}, method2: function() {} };
sinon.stub = function() {
return object;
};
this.collection.stub(object);
assertEquals([object.method, object.method2], this.collection.fakes);
assertEquals(2, this.collection.fakes.length);
},
"should return a stubbed object": function() {
var object = { method: function () {} };
sinon.stub = function () {
return object;
};
assertEquals(object, this.collection.stub(object));
},
"should return a stubbed method": function() {
var object = { method: function () {} };
sinon.stub = function () {
return object.method;
};
assertEquals(object.method, this.collection.stub(object, "method"));
}
});

@@ -125,0 +90,0 @@

@@ -164,24 +164,2 @@ /*jslint onevar: false*/

"should unstub all methods of an objects after test is run": function () {
var myMeth = function () {};
var myMeth2 = function () {};
var myObj = { meth: myMeth, meth2: myMeth2 };
var testCase = sinon.testCase({
testA: function () {
this.stub(myObj);
assertFunction(this.stub);
assertNotSame(myMeth, myObj.meth);
assertNotSame(myMeth2, myObj.meth2);
}
});
testCase.testA();
assertSame(myMeth, myObj.meth);
assertSame(myMeth2, myObj.meth2);
},
"should unstub objects stubbed in setUp": function () {

@@ -207,25 +185,2 @@ var myMeth = function () {};

"should unstub all methods of an objects stubbed in setUp": function () {
var myMeth = function () {};
var myMeth2 = function () {};
var myObj = { meth: myMeth, meth2: myMeth2 };
var testCase = sinon.testCase({
setUp: function () {
this.stub(myObj);
},
testA: function () {
assertFunction(this.stub);
assertNotSame(myMeth, myObj.meth);
assertNotSame(myMeth2, myObj.meth2);
}
});
testCase.testA();
assertSame(myMeth, myObj.meth);
assertSame(myMeth2, myObj.meth2);
},
"should allow the use of helper methods": function () {

@@ -232,0 +187,0 @@ var helper = sinon.spy();

@@ -75,15 +75,2 @@ /*jslint onevar: false, eqeqeq: false, browser: true*/

"should restore stubs on all object methods": function() {
var method = function () {};
var method2 = function () {};
var object = { method: method, method2: method2 };
sinon.test(function () {
this.stub(object);
}).call({});
assertSame(method, object.method);
assertSame(method2, object.method2);
},
"should throw when method throws": function () {

@@ -90,0 +77,0 @@ var method = function () {};

@@ -89,28 +89,3 @@ /*jslint onevar: false, eqeqeq: false, plusplus: false*/

assert(sinon.clock.evalCalled);
},
"should pass setTimeout parameters": function() {
var clock = sinon.clock.create();
var stub = sinon.stub.create();
clock.setTimeout(stub, 2, 'the first', 'the second');
clock.tick(3);
assertEquals(true, stub.calledWithExactly('the first', 'the second'));
},
"should call correct timeout on recursive tick": function() {
var clock = sinon.clock.create(),
stub = sinon.stub.create(),
recurseCallback = function(){
clock.tick(100);
};
clock.setTimeout(recurseCallback, 50);
clock.setTimeout(stub, 100);
clock.tick(50);
assert(stub.called);
}
}
});

@@ -508,13 +483,2 @@

assertEquals(3, stub.callCount);
},
"should pass setTimeout parameters": function() {
var clock = sinon.clock.create();
var stub = sinon.stub.create();
clock.setInterval(stub, 2, 'the first', 'the second');
clock.tick(3);
assertEquals(true, stub.calledWithExactly('the first', 'the second'));
}

@@ -521,0 +485,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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