Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh authored Jun 16, 2022
1 parent 57c09c1 commit 5efcfe3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ You can specify the db response by calling:
tracker.on.select('select * from users where `id`=?').response([{ id: 1, name: 'foo' }]);
```
```ts
tracker.on.select('select * from users where `id`=?').response(rawQuery => [{ id: 1, name: 'foo' }]);
tracker.on
.select('select * from users where `id`=?')
.response((rawQuery) => [{ id: 1, name: 'foo' }]);
```

2. `responseOnce<T = any>(data: T | ((rawQuery: RawQuery) => (T | Promise<T>)))`- This will register a one-time query handler, which will be removed from handlers list after the first usage.
Expand All @@ -125,7 +127,9 @@ You can specify the db response by calling:
tracker.on.select('select * from users where `id`=?').responseOnce([{ id: 1, name: 'foo' }]);
```
```ts
tracker.on.select('select * from users where `id`=?').responseOnce(rawQuery => Promise.resolve([{ id: 1, name: 'foo' }]));
tracker.on
.select('select * from users where `id`=?')
.responseOnce((rawQuery) => Promise.resolve([{ id: 1, name: 'foo' }]));
```

3. `simulateError(errorMessage: string)` - will register a permanent failure handler for the matched
Expand Down Expand Up @@ -182,5 +186,6 @@ You can reset all history calls by calling `tracker.resetHistory()`.

You can reset `queryHandlers` & `history` by calling `tracker.reset()`.


This lib got inspiration from [`axios-mock-adapter`](https://github.com/ctimmerm/axios-mock-adapter)
api️.

0 comments on commit 5efcfe3

Please sign in to comment.