Options
All
  • Public
  • Public/Protected
  • All
Menu

Combine a list of children expectations and gets fulfilled if at least one of the children is.

Children expectations beyond the first fulfilled one get associated to UnresolvedExpectation (they do not need to be evaluated).

The normalized data in case of FulfilledExpectation is the the result of the provided normalizeTo function evaluated from the first fulfilled child.

❕ The function expectAnyOf is generally used to construct AnyOf expectation.

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

Index

Constructors

Properties

Methods

Constructors

constructor

  • new AnyOf<T>(description: string, expectations: IExpectation<T>[], normalizeTo?: (accData: any) => T): AnyOf<T>
  • Type parameters

    • T

    Parameters

    • description: string

      description of the expectation

    • expectations: IExpectation<T>[]

      list of children expectations

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

      defines how to normalize the data from one of the children

        • (accData: any): T
        • Parameters

          • accData: any

          Returns T

    Returns AnyOf<T>

Properties

Readonly description

description: string

description of the expectation

Readonly expectations

expectations: IExpectation<T>[]

Readonly normalizeTo

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

Type declaration

    • (accData: any): T
    • Parameters

      • accData: any

      Returns T

Readonly when

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

Methods

resolve

  • Resolve the expectation

    AnyOf expectation gets fulfilled if at least one of its children is.

    Children expectations beyond the first fulfilled one get associated to UnresolvedExpectation (they do not need to be evaluated).

    The normalized data in case of FulfilledExpectation is the the result of the provided normalizeTo function evaluated from the first fulfilled child.

    Parameters

    • inputData: unknown

      Input data to evaluate the expectation on

    Returns ExpectationStatus<T>

    Expectation status from given inputData

Generated using TypeDoc