{
  "type": "module",
  "source": "doc/api/api-mockclient.md",
  "modules": [
    {
      "textRaw": "Class: MockClient",
      "name": "class:_mockclient",
      "type": "module",
      "desc": "<p>Extends: <code>undici.Client</code></p>\n<p>A mock client class that implements the same api as <a href=\"/docs/docs/api/MockPool.html\">MockPool</a>.</p>",
      "signatures": [
        {
          "textRaw": "`new MockClient(origin, [options])`",
          "name": "MockClient",
          "type": "ctor",
          "params": [
            {
              "name": "origin"
            },
            {
              "name": "options",
              "optional": true
            }
          ],
          "desc": "<p>Arguments:</p>\n<ul>\n<li><strong>origin</strong> <code>string</code> - It should only include the <strong>protocol, hostname, and port</strong>.</li>\n<li><strong>options</strong> <code>MockClientOptions</code> - It extends the <code>Client</code> options.</li>\n</ul>\n<p>Returns: <code>MockClient</code></p>",
          "modules": [
            {
              "textRaw": "Parameter: `MockClientOptions`",
              "name": "parameter:_`mockclientoptions`",
              "type": "module",
              "desc": "<p>Extends: <code>ClientOptions</code></p>\n<ul>\n<li><strong>agent</strong> <code>Agent</code> - the agent to associate this MockClient with.</li>\n</ul>",
              "displayName": "Parameter: `MockClientOptions`"
            },
            {
              "textRaw": "Example - Basic MockClient instantiation",
              "name": "example_-_basic_mockclient_instantiation",
              "type": "module",
              "desc": "<p>We can use MockAgent to instantiate a MockClient ready to be used to intercept specified requests. It will not do anything until registered as the agent to use and any mock request are registered.</p>\n<pre><code class=\"language-js\">import { MockAgent } from 'undici'\n\n// Connections must be set to 1 to return a MockClient instance\nconst mockAgent = new MockAgent({ connections: 1 })\n\nconst mockClient = mockAgent.get('http://localhost:3000')\n</code></pre>",
              "displayName": "Example - Basic MockClient instantiation"
            }
          ]
        }
      ],
      "modules": [
        {
          "textRaw": "Instance Methods",
          "name": "instance_methods",
          "type": "module",
          "methods": [
            {
              "textRaw": "`MockClient.intercept(options)`",
              "name": "intercept",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    }
                  ]
                }
              ],
              "desc": "<p>Implements: <a href=\"/docs/docs/api/MockPool.html#mockpoolinterceptoptions\"><code>MockPool.intercept(options)</code></a></p>"
            },
            {
              "textRaw": "`MockClient.cleanMocks()`",
              "name": "cleanMocks",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Implements: <a href=\"/docs/docs/api/MockPool.html#mockpoolcleanmocks\"><code>MockPool.cleanMocks()</code></a></p>"
            },
            {
              "textRaw": "`MockClient.close()`",
              "name": "close",
              "type": "method",
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>Implements: <a href=\"/docs/docs/api/MockPool.html#mockpoolclose\"><code>MockPool.close()</code></a></p>"
            },
            {
              "textRaw": "`MockClient.dispatch(options, handlers)`",
              "name": "dispatch",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "handlers"
                    }
                  ]
                }
              ],
              "desc": "<p>Implements <a href=\"/docs/docs/api/Dispatcher.html#dispatcherdispatchoptions-handler\"><code>Dispatcher.dispatch(options, handlers)</code></a>.</p>"
            },
            {
              "textRaw": "`MockClient.request(options[, callback])`",
              "name": "request",
              "type": "method",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "options"
                    },
                    {
                      "name": "callback",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>See <a href=\"/docs/docs/api/Dispatcher.html#dispatcherrequestoptions-callback\"><code>Dispatcher.request(options [, callback])</code></a>.</p>",
              "modules": [
                {
                  "textRaw": "Example - MockClient request",
                  "name": "example_-_mockclient_request",
                  "type": "module",
                  "desc": "<pre><code class=\"language-js\">import { MockAgent } from 'undici'\n\nconst mockAgent = new MockAgent({ connections: 1 })\n\nconst mockClient = mockAgent.get('http://localhost:3000')\nmockClient.intercept({ path: '/foo' }).reply(200, 'foo')\n\nconst {\n  statusCode,\n  body\n} = await mockClient.request({\n  origin: 'http://localhost:3000',\n  path: '/foo',\n  method: 'GET'\n})\n\nconsole.log('response received', statusCode) // response received 200\n\nfor await (const data of body) {\n  console.log('data', data.toString('utf8')) // data foo\n}\n</code></pre>",
                  "displayName": "Example - MockClient request"
                }
              ]
            }
          ],
          "displayName": "Instance Methods"
        }
      ],
      "displayName": "Class: MockClient"
    }
  ]
}