Skip to content

Commit

Permalink
Document promise resolution value for waitFor() (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumar303 authored and InterAl committed Mar 25, 2019
1 parent 3a6345a commit b9da616
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ describe('ourSaga test', () => {
sagaTester.dispatch(Actions.actions.start());

// Wait for the saga to finish (it emits the SUCCESS action when its done)
await sagaTester.waitFor(Actions.types.SUCCESS);
const successAction = await sagaTester.waitFor(Actions.types.SUCCESS);

// Check that the success action is what we expect it to be
expect(sagaTester.getLatestCalledAction()).to.deep.equal(
expect(successAction).to.deep.equal(
Actions.actions.success({ data: expectedData })
);
});
Expand Down Expand Up @@ -157,21 +157,23 @@ Dispatches an action to the redux store.

#### `sagaTester.updateState(newState)`

Assigns the `newState` into the current state.
Assigns the `newState` into the current state.
_(Only works with the default reducer.)_

#### `sagaTester.getState() => Object`

Returns the state of the redux store.

#### `sagaTester.waitFor(actionType, futureOnly) => Promise`
#### `sagaTester.waitFor(actionType, futureOnly) => Promise<action>`

Returns a promise that will resolve if the specified action is dispatched to the store.

1. `actionType : String`
2. `futureOnly : Boolean`
* Causes waitFor to only resolve if the action is called in the future.

The promise resolves with the matching `action` object.

#### `sagaTester.wasCalled(actionType) => Boolean`

Returns whether the specified was dispatched in the past.
Expand Down

0 comments on commit b9da616

Please sign in to comment.