Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseExpectation<T>

A simple base class for expectations that may be better suited rather than deriving directly from IExpectation.

Type parameters

  • T

    The type of FulfilledExpectation.value, i.e. the type of the expectation return's value (normalized value) when the expectation is fulfilled

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

  • new BaseExpectation<T>(description: string, when: BaseExpectation<T> | ((inputData: any) => boolean), normalizeTo?: (accData: any) => T): BaseExpectation<T>
  • Type parameters

    • T

    Parameters

    • description: string

      description of the expectation

    • when: BaseExpectation<T> | ((inputData: any) => boolean)

      defines the condition of fulfillment

    • normalizeTo: (accData: any) => T = ...

      defines how to normalize the data

        • (accData: any): T
        • Parameters

          • accData: any

          Returns T

    Returns BaseExpectation<T>

Properties

Readonly description

description: string

description of the expectation

Readonly normalizeTo

normalizeTo: (accData: any) => T = ...

Type declaration

    • (accData: any): T
    • Parameters

      • accData: any

      Returns T

Readonly when

when: BaseExpectation<T> | ((inputData: any) => boolean)

Methods

resolve

  • BaseExpectation gets fulfilled if this.when is from inputData.

    The normalized data in case of FulfilledExpectation is:

    • this.when is of type (inputData) => boolean => this.normalizeTo(inputData)
    • this.when is of type BaseExpectation => normalized value of this.when

    Parameters

    • inputData: unknown

      Input data to evaluate the expectation on

    Returns ExpectationStatus<T>

    Expectation status from given inputData

Generated using TypeDoc