From 9be280d429d7c9070f95999c24c7e259ea4e7c3e Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Tue, 27 Nov 2018 16:22:24 +0000 Subject: [PATCH] Document history property in README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 0cd0541..03e1ac8 100644 --- a/README.md +++ b/README.md @@ -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); + }); +}); +```