UNPKG

1.31 kBTypeScriptView Raw
1/// <reference types="node" />
2import express from 'express';
3import { IncomingMessage, ServerResponse } from 'http';
4import { Listener as ShotListener, RequestOptions as ShotRequestOptions, ResponseObject } from 'shot';
5declare const inject: (dispatchFunc: ShotListener, options: ShotRequestOptions) => Promise<ResponseObject>;
6export { inject, ShotRequestOptions };
7export declare function stubServerRequest(options: ShotRequestOptions): IncomingMessage;
8export type ShotCallback = (response: ResponseObject) => void;
9export type ShotResponseCtor = new (request: IncomingMessage, onEnd: ShotCallback) => ServerResponse;
10export declare function stubServerResponse(request: IncomingMessage, onEnd: ShotCallback): ServerResponse;
11export type ObservedResponse = ResponseObject;
12export interface HandlerContextStub {
13 request: IncomingMessage;
14 response: ServerResponse;
15 result: Promise<ObservedResponse>;
16}
17export declare function stubHandlerContext(requestOptions?: ShotRequestOptions): HandlerContextStub;
18export interface ExpressContextStub extends HandlerContextStub {
19 app: express.Application;
20 request: express.Request;
21 response: express.Response;
22 result: Promise<ObservedResponse>;
23}
24export declare function stubExpressContext(requestOptions?: ShotRequestOptions): ExpressContextStub;