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

deride

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deride - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

21

lib/deride.js

@@ -102,3 +102,21 @@ /*

}
function matchExactly() {
var expectedArgs = _.values(arguments);
var matched = true;
_.forEach(calledWithArgs, function (args) {
_.forEach(_.values(args), function (arg, i) {
if (!_.isEqual(arg, expectedArgs[i])) {
matched = false;
debug('is object match?', matched, arg, expectedArgs[i]);
return;
}
debug('is match?', matched, arg, expectedArgs[i]);
});
});
if (!matched) {
assert.fail(calledWithArgs, expectedArgs, 'Expected ' + method + ' to be called matchExactly args' + require('util').inspect(expectedArgs, {depth: 10}));
}
}
function objectPatternMatchProperties(obj, pattern) {

@@ -226,2 +244,3 @@ var matched = false;

reset: reset,
matchExactly: matchExactly,
withArgs: withArgs,

@@ -228,0 +247,0 @@ withArg: withSingleArg,

2

package.json
{
"name": "deride",
"description": "Mocking library based on composition",
"version": "0.5.3",
"version": "0.5.4",
"homepage": "https://github.com/guzzlerio/deride",

@@ -6,0 +6,0 @@ "author": {

@@ -42,2 +42,3 @@ # deride [![Build Status](https://travis-ci.org/guzzlerio/deride.svg?branch=master)](https://travis-ci.org/guzzlerio/deride) [![NPM version](https://badge.fury.io/js/deride.svg)](http://badge.fury.io/js/deride) [![Dependency Status](https://david-dm.org/guzzlerio/deride.svg)](https://david-dm.org/guzzlerio/deride) [![Stories in Ready](https://badge.waffle.io/guzzlerio/deride.png?label=ready&title=Ready)](https://waffle.io/guzzlerio/deride) [![Stories In Progress](https://badge.waffle.io/guzzlerio/deride.png?label=in%20progress&title=In%20Progres)](https://waffle.io/guzzlerio/deride)

- [```obj```.expect.```method```.called.withMatch(pattern)](#called-withmatch)
- [```obj```.expect.```method```.called.matchExactly(args)](#called-matchexactly)

@@ -252,2 +253,12 @@ **All of the above can be negated e.g. negating the `.withArgs` would be: **

<a name="called-matchexactly" />
### Determine if a method was called with the exact set of arguments
```javascript
var bob = new Person('bob');
bob = deride.wrap(bob);
bob.greet('alice', ['james'], 987);
bob.expect.greet.called.matchExactly('alice', ['james'], 987);
```
<a name="setup-todothis" />

@@ -254,0 +265,0 @@

@@ -84,3 +84,3 @@ /*

describe.only('Expectations', function() {
describe('Expectations', function() {
var bob;

@@ -204,2 +204,25 @@ beforeEach(function () {

});
describe('matchExactly causes failures', function () {
it('with mixed strings, arrays and numbers', function () {
bob.greet('alice', ['carol'], 123);
(function () {
bob.expect.greet.called.matchExactly('not-alice', ['or-carol'], 987);
}).should.throw('Expected greet to be called matchExactly args[ \'not-alice\', [ \'or-carol\' ], 987 ]');
});
it('with mixture of primitives and objects', function () {
bob.greet('alice', ['carol'], 123, {
name: 'bob',
a: 1
}, 'sam');
(function () {
bob.expect.greet.called.matchExactly('alice', ['carol'], 123, {
name: 'not-bob',
a: 1
}, 'not-sam');
}).should.throw('Expected greet to be called matchExactly args[ \'alice\', [ \'carol\' ], 123, { name: \'not-bob\', a: 1 }, \'not-sam\' ]');
});
});
});

@@ -485,2 +508,70 @@

describe(test.name + ':matchExactly', function () {
beforeEach(function(done) {
bob = test.setup();
done();
});
it('with a primitive string', function (done) {
bob.greet('bob');
bob.expect.greet.called.matchExactly('bob');
done();
});
it('with multiple a primitive strings', function (done) {
bob.greet('alice', 'carol');
bob.expect.greet.called.matchExactly('alice', 'carol');
done();
});
it('with mixed strings, arrays and numbers', function (done) {
bob.greet('alice', ['carol'], 123);
bob.expect.greet.called.matchExactly('alice', ['carol'], 123);
done();
});
it('with mixture of primitives and objects', function () {
bob.greet('alice', ['carol'], 123, {
name: 'bob',
a: 1
}, 'sam');
bob.expect.greet.called.matchExactly('alice', ['carol'], 123, {
name: 'bob',
a: 1
}, 'sam');
});
it('with a frozen object', function () {
bob.greet(Object.freeze({
name: 'bob',
a: 1
}), 'sam');
bob.expect.greet.called.matchExactly(Object.freeze({
name: 'bob',
a: 1
}), 'sam');
});
it('with same instance', function () {
var Obj = function() {
return {
times: function (arg) {
return arg;
}
};
};
var o = new Obj();
bob.greet(o);
bob.expect.greet.called.matchExactly(o);
});
it('with a function', function () {
var func = function() {
return 12345;
};
bob.greet(func);
bob.expect.greet.called.matchExactly(func);
});
});
describe(test.name + ':invocation', function() {

@@ -487,0 +578,0 @@ beforeEach(function(done) {

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