simple-mock
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -181,2 +181,10 @@ /* global define */ | ||
newFn.withActions = function (actions) { | ||
wrappedFn = stubFn | ||
if (actions && actions.length >= 0) { | ||
Array.prototype.push.apply(newFn.actions, actions) | ||
} | ||
return newFn // Chainable | ||
} | ||
newFn.callOriginal = newFn.callOriginalFn = function () { | ||
@@ -183,0 +191,0 @@ wrappedFn = stubFn |
{ | ||
"name": "simple-mock", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Super simple stubs and spies with 1-step sandbox restore", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -159,3 +159,3 @@ # simple-mock | ||
### spy.restore() | ||
### spy.reset() | ||
@@ -207,2 +207,26 @@ Resets all counts and properties to the original state. | ||
Note: modifying this array directly is not supported, rather use stub.withActions(actions) if you need to add actions. | ||
### stub.withActions(actions) *or* stub.withActions() | ||
Configures this stub to use the specified array of actions. See `stub.actions` above for the syntax of an action. | ||
```js | ||
var fn = simple.stub() | ||
.returnWith('a') | ||
.withActions([{ returnValue: 'b' }, { returnValue: 'c' }]) | ||
.returnWith('d') | ||
var returned1 = fn() | ||
var returned2 = fn() | ||
var returned3 = fn() | ||
var returned4 = fn() | ||
assert.equal(fn.callCount, 4) | ||
assert.equal(returned1, 'a') | ||
assert.equal(returned2, 'b') | ||
assert.equal(returned3, 'c') | ||
assert.equal(returned4, 'd') | ||
``` | ||
### stub.loop | ||
@@ -209,0 +233,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26965
9
599
241
1