@s-libs/ng-dev
    Preparing search index...

    Class SlTestRequest<Body>

    A class very similar to Angular's TestRequest for use with an AngularContext. If you are using an AngularContext, this will trigger change detection automatically after you flush a response, like production behavior.

    Though it is possible to construct yourself, normally an instance of this class is obtained from ().

    const ctx = new AngularContext({ providers: [provideHttpClient()] });
    ctx.run(() => {
    inject(HttpClient)
    .get('http://example.com', { params: { key: 'value' } })
    .subscribe();
    const request = expectRequest<string>('GET', 'http://example.com', {
    params: { key: 'value' },
    });
    request.flush('my response body');
    });

    Type Parameters

    • Body extends HttpBody
    Index

    Constructors

    Properties

    Methods

    Constructors

    • Type Parameters

      • Body extends
            | null
            | string
            | number
            | boolean
            | Object
            | ArrayBuffer
            | Blob
            | (null | string | number | boolean | Object)[]

      Parameters

      • req: TestRequest

      Returns SlTestRequest<Body>

    Properties

    request: HttpRequest<any>

    The underlying TestRequest object from Angular.

    Methods

    • Resolve the request with the given body and options, like TestRequest.flush().

      Parameters

      • body: Body
      • Optionalopts: {
            headers?: HttpHeaders | { [name: string]: string | string[] };
            status?: number;
            statusText?: string;
        }

      Returns void

    • Convenience method to flush an error response.

      Parameters

      • status: number = 500
      • __namedParameters: {
            body?:
                | null
                | string
                | number
                | boolean
                | Object
                | ArrayBuffer
                | Blob
                | (null | string | number | boolean | Object)[];
            statusText?: string;
        } = {}

      Returns void