///
///
///
declare module "@hatsy/hatsy/testing.js" {
import { IncomingMessage, RequestListener, RequestOptions, Server } from "node:http";
import type { AddressInfo } from "node:net";
import { RequestHandler } from "@hatsy/hatsy/core.js";
import { HttpConfig } from "@hatsy/hatsy";
import { HttpMeans } from "@hatsy/hatsy";
/**
* Testing HTTP server and client.
*/
export class TestHttpServer {
#private;
/**
* Starts new test HTTP server and binds it ro random port ad localhost.
*
* @returns A promise resolved to started server.
*/
static start(): Promise;
private constructor();
/**
* HTTP server instance.
*/
get server(): Server;
/**
* An address the service is bound to.
*/
get address(): AddressInfo;
/**
* Starts to handle incoming requests by the given request listener.
*
* @param listener - New HTTP request listener.
*
* @returns `this` instance.
*/
listenBy(listener: RequestListener): this;
/**
* Starts to handle extended incoming requests by the given request handler.
*
* @typeParam TExt - Request processing means extension type.
* @param config - HTTP processing configuration.
* @param handler - New HTTP request processing handler.
*
* @returns `this` instance.
*/
handleBy(config: HttpConfig.Extended, handler: RequestHandler): this;
/**
* Starts to handle incoming requests by the given request handler.
*
* @param config - HTTP processing configuration.
* @param handler - New HTTP request processing handler.
*
* @returns `this` instance.
*/
handleBy(config: HttpConfig, handler: RequestHandler): this;
/**
* Starts to handle incoming requests by the given request handler according to default configuration.
*
* @param handler - New HTTP request processing handler.
*
* @returns `this` instance.
*/
handleBy(handler: RequestHandler): this;
/**
* Posts the data to the test server.
*
* @param path - Request path.
* @param body - Request body to post, or `undefined` to post nothing.
* @param options - Request options. The default request method is `POST`.
*
* @returns A promise resolves to server response.
*/
post(path: string, body?: string | Buffer, options?: RequestOptions): Promise;
/**
* Requests the data from the test server.
*
* @param path - Request path.
* @param options - Request options. The default request method is `GET`.
*
* @returns A promise resolves to server response.
*/
get(path: string, options?: RequestOptions): Promise;
/**
* Stops this server.
*
* @returns A promise resolved when the server is stopped.
*/
stop(): Promise;
}
export namespace TestHttpServer {
/**
* A response of test HTTP server.
*/
interface Response extends IncomingMessage {
/**
* Reads response body.
*
* @returns A promise resolved to response body.
*/
body(): Promise;
}
}
}
//# sourceMappingURL=hatsy.testing.d.ts.map