Skip to content

Commit 0ea3e17

Browse files
committed
Add docs for stub.value
1 parent c89fb21 commit 0ea3e17

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/release-source/release/stubs.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,31 @@ myObj.prop = 'baz';
520520

521521
myObj.example; // 'baz'
522522
```
523+
524+
#### `stub.value(newVal)`
525+
526+
Defines a new value for this stub.
527+
528+
```javascript
529+
var myObj = {
530+
example: 'oldValue',
531+
};
532+
533+
sinon.stub(myObj, 'example').value('newValue');
534+
535+
myObj.example; // 'newValue'
536+
```
537+
538+
You can restore values by calling the `restore` method:
539+
540+
```javascript
541+
var myObj = {
542+
example: 'oldValue',
543+
};
544+
545+
var stub = sinon.stub(myObj, 'example').value('newValue');
546+
stub.restore()
547+
548+
myObj.example; // 'oldValue'
549+
```
550+

0 commit comments

Comments
 (0)