Skip to content

Commit

Permalink
Add docs for stub.value
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed May 21, 2017
1 parent c89fb21 commit 0ea3e17
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/release-source/release/stubs.md
Expand Up @@ -520,3 +520,31 @@ myObj.prop = 'baz';

myObj.example; // 'baz'
```

#### `stub.value(newVal)`

Defines a new value for this stub.

```javascript
var myObj = {
example: 'oldValue',
};

sinon.stub(myObj, 'example').value('newValue');

myObj.example; // 'newValue'
```

You can restore values by calling the `restore` method:

```javascript
var myObj = {
example: 'oldValue',
};

var stub = sinon.stub(myObj, 'example').value('newValue');
stub.restore()

myObj.example; // 'oldValue'
```

0 comments on commit 0ea3e17

Please sign in to comment.