Skip to content

Commit

Permalink
Merge pull request #1242 from Floby/add-documentation-for-promise-stub
Browse files Browse the repository at this point in the history
Add documentation for .rejects() and .resolves()
  • Loading branch information
fatso83 authored Jan 11, 2017
2 parents 9368d15 + 0d778ee commit 1760b8c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/release-source/release/stubs.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ Causes the stub to return its <code>this</code> value.

Useful for stubbing jQuery-style fluent APIs.

#### `stub.resolves(value);`

Causes the stub to return a Promise which resolves to the provided value.

When constructing the Promise, sinon uses the `Promise.resolve` method. You are
responsible for providing a polyfill in environments which do not provide `Promise`.

*Since `sinon@2.0.0`*


#### `stub.throws();`

Expand All @@ -242,6 +251,30 @@ Causes the stub to throw an exception of the provided type.
Causes the stub to throw the provided exception object.


#### `stub.rejects();`

Causes the stub to return a Promise which rejects with an exception (`Error`).

When constructing the Promise, sinon uses the `Promise.reject` method. You are
responsible for providing a polyfill in environments which do not provide `Promise`.

*Since `sinon@2.0.0`*


#### `stub.rejects("TypeError");`

Causes the stub to return a Promise which rejects with an exception of the provided type.

*Since `sinon@2.0.0`*


#### `stub.rejects(value);`

Causes the stub to return a Promise which rejects with the provided exception object.

*Since `sinon@2.0.0`*


#### `stub.callsArg(index);`

Causes the stub to call the argument at the provided index as a callback function. `stub.callsArg(0);` causes the stub to call the first argument as a callback.
Expand Down

0 comments on commit 1760b8c

Please sign in to comment.