Skip to content

Commit

Permalink
Merge pull request #14 from lifeomic/doc-followups
Browse files Browse the repository at this point in the history
fix: final doc adjustments and stop exported undocumented function
  • Loading branch information
swain authored Oct 21, 2022
2 parents f3bc83b + 3d7530a commit 0cac295
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ cache.updateCache(
`one-query` also provides a testing utility for doing type-safe mocking of API endpoints in tests. This utility is powered by [`msw`](https://github.com/mswjs/msw).
### `createAPIMockingUtility`
### `createAPIMockingUtility(...)`
If you're using [`jest`](https://jestjs.io/) for testing, use `createAPIMockingUtility` to create a shareable utility for mocking network calls.
Expand All @@ -421,11 +421,20 @@ If you're using [`jest`](https://jestjs.io/) for testing, use `createAPIMockingU
export const useAPIMocking = createAPIMockingUtility<APIEndpoints>({
baseUrl: 'https://my.api.com',
});

// another-file.ts
const api = useAPIMocking();

// now, any mocks applied during tests will be automatically cleaned up + cleared
// before each test
test('something', () => {
api.mock(...)
});
```
### `mock(route, mocker)`
Mocks the specified route with the specified mocker _persistently_.
Mocks the specified route with the specified mocker _persistently_. The provided mock response will be used indefinitely until it is removed or replaced.
```typescript
const api = useAPIMocking();
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type APIMocker<Endpoints extends RoughEndpoints> = {
reset: () => void;
};

export const createAPIMocker = <Endpoints extends RoughEndpoints>(
const createAPIMocker = <Endpoints extends RoughEndpoints>(
server: SetupServerApi,
baseUrl: string,
): APIMocker<Endpoints> => {
Expand Down

0 comments on commit 0cac295

Please sign in to comment.