Go to repository

Class FullExpectation

The expectation class is the class that is actually instantiated for any expectation. It implements all interfaces for expectations, even the finished expectation ones.

Hierarchy (view full)

Constructors

Create a new expectation for the given element.

Parameters

  • element: unknown

    The element to query to.

Returns FullExpectation

Properties

Protected
element: unknown

The querying element of this expectation.

Protected
isNot: boolean

true if this expectation is a negated expectation, that is, the not property was accessed.

Protected
result: boolean

The current result of this expectation. Undefined until the first matcher is run.

Protected
states: MatcherCall[]

An array of the matchers run in this expectation.

Accessors

get not(): this

Methods

Parameters

  • criteria: ((item: unknown) => boolean)
      • (item): boolean
      • Parameters

        • item: unknown

        Returns boolean

Returns FullExpectation & FinishedExpectation

Parameters

  • count: number
  • criteria: ((item: unknown) => boolean)
      • (item): boolean
      • Parameters

        • item: unknown

        Returns boolean

Returns FullExpectation & FinishedExpectation

If the result of the expectation is true, run the given function.

Parameters

  • action: (() => void)
      • (): void
      • Returns void

Returns void

If the result of the expectation is true, run the first of the functions, if false, run the second one.

Parameters

  • actionWhenTrue: (() => void)
      • (): void
      • Returns void

  • actionWhenFalse: (() => void)
      • (): void
      • Returns void

Returns void

Parameters

  • criteria: ((item: unknown) => boolean)
      • (item): boolean
      • Parameters

        • item: unknown

        Returns boolean

Returns FullExpectation & FinishedExpectation

Return's the result of the expectancy as a boolean.

Returns boolean

true if the value satisfied the expectation, falseotherwise.

If the result of the expectation is false, run the given function.

Parameters

  • action: (() => void)
      • (): void
      • Returns void

Returns void

If the result of the expectation is false, throw the given error.

Parameters

Returns void

If the result of the expectation is false, return the given value.

Type Parameters

  • T

Parameters

  • value: T

Returns T

Protected

Run a matcher with the given name, passing the querying element as a first argument, and all additional given arguments. The result of running the matcher is stores, and a new state is pushed to this particular matcher.

Parameters

  • matcherName: string

    The matcher name to run

  • args: unknown[]

    The arguments to pass to the matcher

  • sparse: boolean = true

Returns this

Protected

Set the given value as the result of this expectation. The result is directly set, when no previous result existed, or joined with a logic conjunction with the previous result if a value already exists.

Parameters

  • value: boolean

    The value to set.

Returns void