Skip to content

Commit

Permalink
Document history property in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lbennett-stacki committed Nov 27, 2018
1 parent 8681af9 commit 9be280d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -258,3 +258,26 @@ mock
)
);
```

## History

The `history` property allows you to enumerate existing axios request objects. The property is an object of verb keys referencing arrays of request objects.

This is useful for testing.

```js
describe('Feature', () => {
it('requests an endpoint', (done) => {
var mock = new AxiosMockAdapter(axios);
mock.onPost('/endpoint').replyOnce(200);

feature.request()
.then(() => {
expect(mock.history.post.length).toBe(1);
expect(mock.history.post[0].data).toBe(JSON.stringify({ foo: 'bar' }));
})
.then(done)
.catch(done.fail);
});
});
```

0 comments on commit 9be280d

Please sign in to comment.