@opra/testing
Version:
Opra testing package
53 lines (52 loc) • 1.9 kB
TypeScript
import '../expect-extend/index.js';
import { ApiExpectBase } from './api-expect-base.js';
import { ApiExpectCollection } from './api-expect-collection.js';
import { ApiExpectError } from './api-expect-error.js';
import { ApiExpectObject } from './api-expect-object.js';
import { ApiExpectOperationResult } from './api-expect-operation-result.js';
/**
* Main entry point for API assertions.
*
* @class ApiExpect
*/
export declare class ApiExpect extends ApiExpectBase {
/**
* Asserts that the request was successful (status code 200-399).
*
* @param status Optional expected status code.
* @returns The current ApiExpect instance.
* @throws {@link Error} if the assertion fails.
*/
toSuccess(status?: number): this;
/**
* Asserts that the request failed (status code 400-599).
*
* @param status Optional expected status code.
* @returns An {@link ApiExpectError} instance.
* @throws {@link Error} if the assertion fails.
*/
toFail(status?: number): ApiExpectError;
/**
* Asserts that the API returned a Collection.
*
* @returns An {@link ApiExpectCollection} instance.
* @throws {@link Error} if the assertion fails.
*/
toReturnCollection(): ApiExpectCollection;
/**
* Asserts that the API returned an Object.
*
* @param contentType Optional expected Content-Type header value.
* @returns An {@link ApiExpectObject} instance.
* @throws {@link Error} if the assertion fails.
*/
toReturnObject(contentType?: string): ApiExpectObject;
/**
* Asserts that the API returned an OperationResult.
*
* @returns An {@link ApiExpectOperationResult} instance.
* @throws {@link Error} if the assertion fails.
*/
toReturnOperationResult(): ApiExpectOperationResult;
protected _parseBodyErrors(errors: any[]): string | undefined;
}