Skip to content

Commit

Permalink
add docs for callThroughWithNew
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinfarris committed Jul 23, 2019
1 parent 8e00c22 commit 85d3f2a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/release-source/release/stubs.md
Expand Up @@ -405,6 +405,27 @@ obj.sum.callThrough();

obj.sum(2, 2); // 'bar'
obj.sum(1, 2); // 3


#### `stub.callThroughWithNew();`

Causes the original method wrapped into the stub to be called using the `new` operator when none of the conditional stubs are matched.

```javascript
var obj = {};
obj.Sum = function MyConstructor(a, b) {
this.result = a + b;
};
sinon
.stub(obj, 'Sum')
.callThroughWithNew()
.withArgs(1, 2)
.returns({ result: 9000 });
(new obj.Sum(2, 2)).result; // 4
(new obj.Sum(1, 2)).result; // 9000
```


Expand Down

0 comments on commit 85d3f2a

Please sign in to comment.