UNPKG

@athenna/http

Version:

The Athenna Http server. Built on top of fastify.

100 lines (99 loc) 2.69 kB
/** * @athenna/http * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import { Assert } from '@japa/assert'; import { Macroable } from '@athenna/common'; import type { InjectOptions } from '#src/types'; import { TestResponse } from '#src/testing/plugins/request/TestResponse'; export declare class TestRequest extends Macroable { /** * Japa assert class instance. */ assert: Assert; /** * Instantiate TestResponse class from API response. */ createResponse(response: any): TestResponse; /** * Make a GET request to the given URL and options. * * @example * ```js * const response = await request.get('/users') * * response.assertStatusCode(200) * ``` */ get(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a HEAD request to the given URL and options. * * @example * ```js * const response = await request.head('/users') * * response.assertStatusCode(200) * ``` */ head(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a OPTIONS request to the given URL and options. * * @example * ```js * const response = await request.options('/users') * * response.assertStatusCode(200) * ``` */ options(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a POST request to the given URL and options. * * @example * ```js * const response = await request.post('/users') * * response.assertStatusCode(200) * ``` */ post(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a PUT request to the given URL and options. * * @example * ```js * const response = await request.put('/users') * * response.assertStatusCode(200) * ``` */ put(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a PATCH request to the given URL and options. * * @example * ```js * const response = await request.patch('/users') * * response.assertStatusCode(200) * ``` */ patch(url: string, options?: InjectOptions): Promise<TestResponse>; /** * Make a DELETE request to the given URL and options. * * @example * ```js * const response = await request.delete('/users') * * response.assertStatusCode(200) * ``` */ delete(url: string, options?: InjectOptions): Promise<TestResponse>; }