diff --git a/packages/client/src/test-utils/HTTPClientMock.ts b/packages/client/src/test-utils/HTTPClientMock.ts index 1edf321..9ddd976 100644 --- a/packages/client/src/test-utils/HTTPClientMock.ts +++ b/packages/client/src/test-utils/HTTPClientMock.ts @@ -1,7 +1,8 @@ import {HTTPClient} from '../http/HTTPClient' -import {IRoutes} from '@rondo/common' import {IRequest} from '../http/IRequest' import {IResponse} from '../http/IResponse' +import {IRoutes, TMethod} from '@rondo/common' +import {ITypedRequestParams} from '../http/ITypedRequestParams' interface IReqRes { req: IRequest @@ -94,6 +95,22 @@ export class HTTPClientMock extends HTTPClient { return this } + /** + * Adds a new mock with predefined type + */ + mockAddTyped

( + params: ITypedRequestParams, + response: T[P][M]['response'], + ): this { + const url = this.formatter.format(params.path, params.params) + return this.mockAdd({ + method: params.method, + url, + params: params.query, + data: params.body, + }, response) + } + /** * Clear all mocks and recorded requests */