Skip to content

Commit

Permalink
docs: fix url in documentation website
Browse files Browse the repository at this point in the history
  • Loading branch information
blephy committed Jan 28, 2025
1 parent 5ca878c commit 882af1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
25 changes: 13 additions & 12 deletions docs/docs/api/MockCallHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ Access to an instance with :
```js
const mockAgent = new MockAgent({ enableCallHistory: true })
mockAgent.getCallHistory()

// or
const mockAgent = new MockAgent()
mockAgent.enableMockHistory()
mockAgent.getCallHistory()
// or

// or
const mockAgent = new MockAgent()
const mockClient = mockAgent.get('http://localhost:3000')
mockClient
Expand Down Expand Up @@ -69,7 +70,7 @@ mockAgent.getCallHistory()?.nthCall(3) // the third MockCallHistoryLog registere
Filter MockCallHistoryLog by protocol.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByProtocol(/https/)
Expand All @@ -80,7 +81,7 @@ mockAgent.getCallHistory()?.filterCallsByProtocol('https:')
Filter MockCallHistoryLog by host.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByHost(/localhost/)
Expand All @@ -91,7 +92,7 @@ mockAgent.getCallHistory()?.filterCallsByHost('localhost:3000')
Filter MockCallHistoryLog by port.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByPort(/3000/)
Expand All @@ -103,7 +104,7 @@ mockAgent.getCallHistory()?.filterCallsByPort('')
Filter MockCallHistoryLog by origin.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByOrigin(/http:\/\/localhost:3000/)
Expand All @@ -114,7 +115,7 @@ mockAgent.getCallHistory()?.filterCallsByOrigin('http://localhost:3000')
Filter MockCallHistoryLog by path.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByPath(/api\/v1\/graphql/)
Expand All @@ -125,7 +126,7 @@ mockAgent.getCallHistory()?.filterCallsByPath('/api/v1/graphql')
Filter MockCallHistoryLog by hash.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByPath(/hash/)
Expand All @@ -136,7 +137,7 @@ mockAgent.getCallHistory()?.filterCallsByPath('#hash')
Filter MockCallHistoryLog by fullUrl. fullUrl contains protocol, host, port, path, hash, and query params
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByFullUrl(/https:\/\/localhost:3000\/\?query=value#hash/)
Expand All @@ -147,7 +148,7 @@ mockAgent.getCallHistory()?.filterCallsByFullUrl('https://localhost:3000/?query=
Filter MockCallHistoryLog by method.
> more details for the first parameter can be found [here](#filter-parameter)
> more details for the first parameter can be found [here](/docs/docs/api/MockCallHistory.md#filter-parameter)
```js
mockAgent.getCallHistory()?.filterCallsByMethod(/POST/)
Expand All @@ -163,21 +164,21 @@ Parameters :
- criteria : the first parameter. a function, regexp or object.
- function : filter MockCallHistoryLog when the function returns false
- regexp : filter MockCallHistoryLog when the regexp does not match on MockCallHistoryLog.toString() ([see](./MockCallHistoryLog.md#to-string))
- object : an object with MockCallHistoryLog properties as keys to apply multiple filters. each values are a [filter parameter](#filter-parameter)
- object : an object with MockCallHistoryLog properties as keys to apply multiple filters. each values are a [filter parameter](/docs/docs/api/MockCallHistory.md#filter-parameter)
- options : the second parameter. an object.
- options.operator : `'AND'` or `'OR'` (default `'OR'`). Used only if criteria is an object. see below
```js
mockAgent.getCallHistory()?.filterCalls((log) => log.hash === value && log.headers?.['authorization'] !== undefined)
mockAgent.getCallHistory()?.filterCalls(/"data": "{ "errors": "wrong body" }"/)

// returns MockCallHistoryLog which have
// returns an Array of MockCallHistoryLog which all have
// - a hash containing my-hash
// - OR
// - a path equal to /endpoint
mockAgent.getCallHistory()?.filterCalls({ hash: /my-hash/, path: '/endpoint' })

// returns MockCallHistoryLog which have
// returns an Array of MockCallHistoryLog which all have
// - a hash containing my-hash
// - AND
// - a path equal to /endpoint
Expand Down
2 changes: 2 additions & 0 deletions docs/docsify/sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* [MockClient](/docs/api/MockClient.md "Undici API - MockClient")
* [MockPool](/docs/api/MockPool.md "Undici API - MockPool")
* [MockAgent](/docs/api/MockAgent.md "Undici API - MockAgent")
* [MockCallHistory](/docs/api/MockCallHistory.md "Undici API - MockCallHistory")
* [MockCallHistoryLog](/docs/api/MockCallHistoryLog.md "Undici API - MockCallHistoryLog")
* [MockErrors](/docs/api/MockErrors.md "Undici API - MockErrors")
* [API Lifecycle](/docs/api/api-lifecycle.md "Undici API - Lifecycle")
* [Diagnostics Channel Support](/docs/api/DiagnosticsChannel.md "Diagnostics Channel Support")
Expand Down

0 comments on commit 882af1e

Please sign in to comment.