New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

testdouble

Package Overview
Dependencies
Maintainers
2
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testdouble - npm Package Compare versions

Comparing version 0.7.3 to 0.8.0

generated/args-match.js

37

generated/test/lib/when-test.js

@@ -154,2 +154,39 @@ // Generated by CoffeeScript 1.10.0

});
describe('stubbing actions with `thenDo` instead of `thenReturn`', function() {
Given(function() {
return this.verify = requireSubject('lib/verify');
});
Given(function() {
return this.someAction = this["function"]();
});
Given(function() {
return this.when(this.testDouble(55)).thenDo(this.someAction);
});
When(function() {
return this.testDouble(55);
});
return Then(function() {
return this.verify(this.someAction(55));
});
});
describe('stubbing actions with `thenThrow` instead of `thenReturn`', function() {
Given(function() {
return this.error = new Error('lol');
});
Given(function() {
return this.when(this.testDouble(42)).thenThrow(this.error);
});
When(function() {
var e, error;
try {
return this.testDouble(42);
} catch (error) {
e = error;
return this.result = e;
}
});
return Then(function() {
return this.error === this.result;
});
});
return describe('config object', function() {

@@ -156,0 +193,0 @@ describe('ignoring extra arguments', function() {

2

generated/test/node-helper.js
// Generated by CoffeeScript 1.10.0
(function() {
global.testdouble = require('./../lib/testdouble');
global.testdouble = require('./../src/testdouble');

@@ -5,0 +5,0 @@ global._ = require('lodash');

// Generated by CoffeeScript 1.10.0
(function() {
var _, argsMatch, callsStore, hasTimesRemaining, isSatisfied, store, stubbedValueFor, stubbingFor;
var _, argsMatch, callsStore, executePlan, hasTimesRemaining, isSatisfied, store, stubbedValueFor, stubbingFor;

@@ -27,5 +27,3 @@ _ = require('lodash');

}
return _.tap(stubbedValueFor(stubbing), function() {
return stubbing.callCount += 1;
});
return executePlan(stubbing, args);
},

@@ -43,2 +41,16 @@ "for": function(testDouble) {

executePlan = function(stubbing, args) {
var value;
value = stubbedValueFor(stubbing);
stubbing.callCount += 1;
switch (stubbing.config.plan) {
case "thenReturn":
return value;
case "thenDo":
return value.apply(null, args);
case "thenThrow":
throw value;
}
};
stubbedValueFor = function(stubbing) {

@@ -45,0 +57,0 @@ if (stubbing.callCount < stubbing.stubbedValues.length) {

// Generated by CoffeeScript 1.10.0
(function() {
var calls, stubbings,
var _, addStubbing, calls, stubbings,
slice = [].slice;
_ = require('lodash');
calls = require('./store/calls');

@@ -16,10 +18,15 @@

thenReturn: function() {
var last, stubbedValues;
var stubbedValues;
stubbedValues = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (last = calls.pop()) {
stubbings.add(last.testDouble, last.args, stubbedValues, config);
return last.testDouble;
} else {
throw new Error("No test double invocation call detected for `when()`.\n\n Usage:\n when(myTestDouble('foo')).thenReturn('bar')");
}
return addStubbing(stubbedValues, config, 'thenReturn');
},
thenDo: function() {
var stubbedValues;
stubbedValues = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return addStubbing(stubbedValues, config, 'thenDo');
},
thenThrow: function() {
var stubbedValues;
stubbedValues = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return addStubbing(stubbedValues, config, 'thenThrow');
}

@@ -29,2 +36,15 @@ };

addStubbing = function(stubbedValues, config, plan) {
var last;
_.assign(config, {
plan: plan
});
if (last = calls.pop()) {
stubbings.add(last.testDouble, last.args, stubbedValues, config);
return last.testDouble;
} else {
throw new Error("No test double invocation call detected for `when()`.\n\n Usage:\n when(myTestDouble('foo')).thenReturn('bar')");
}
};
}).call(this);
{
"name": "testdouble",
"version": "0.7.3",
"version": "0.8.0",
"description": "A minimal test double library for TDD with JavaScript",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/testdouble/testdouble.js",

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

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 not supported yet

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