Skip to content

Commit

Permalink
Merge pull request #184 from Financial-Times/fetch-mock-docs
Browse files Browse the repository at this point in the history
Include documentation for mocking http requests
  • Loading branch information
benbarnett committed Oct 4, 2018
2 parents 0eb75eb + 9ca2a80 commit 34ee092
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions docs/components/stories.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ exports.knobs = require('./knobs');

Story modules export the configuration required for each component demo.

Property | Description | Required
---------|-------------------------------------------------------------|----------
`title` | The title of the story | Yes
`data` | The data to pass as props to the component | Yes
`knobs` | An array of data properties to convert to interactive knobs | No
| Property | Description | Required |
|-------------|--------------------------------------------------------------------------------------------------------------------------------|----------|
| `title` | The title of the story | Yes |
| `data` | The data to pass as props to the component | Yes |
| `knobs` | An array of data properties to convert to interactive knobs | No |
| `fetchMock` | A function expecting an instance of [fetch-mock]. If your story makes HTTP requests, you can use this to mock their behaviour. | No |

Here is an example story configuration:

Expand All @@ -70,8 +71,14 @@ exports.knobs = [
'question'
'answer'
];

// A function expecting a clean instance of fetch-mock
exports.fetchMock = fetchMock => {
fetchMock.mock('/api/data', { some: 'data' });
}
```

[fetch-mock]: https://www.wheresrhys.co.uk/fetch-mock

## Knobs configuration

Expand Down

0 comments on commit 34ee092

Please sign in to comment.