Go to repository

Interface NumberExpectation

This interface represents an expectation that is performed over a number.

Hierarchy (view full)

Properties

This attribute retrieves an expectancy whose result value is false in case the matcher fulfills, and true otherwise.

Methods

Answer the given expectation as an instance of IArrayExpectation. No check is performed on the input to see if it can actually be casted.

Type Parameters

  • E

Returns ArrayExpectation<E>

Answer the given expectation as an instance of INumberExpectation. No check is performed on the input to see if it can actually be casted.

Returns NumberExpectation

Answer the given expectation as an instance of IObjectExpectation. No check is performed on the input to see if it can actually be casted.

Type Parameters

  • E

Returns ObjectExpectation<E>

Answer the given expectation as an instance of IStringExpectation. No check is performed on the input to see if it can actually be casted.

Returns StringExpectation

Answers if the actual value is the same as expected, using strict compare. Do not use toBe with floating point numbers, use Expectations/Matchers.toBeCloseTo instead.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is between the from and to values (inclusive).

Parameters

  • from: number
  • to: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is close to the expected value, by at least the number of digits given.

Parameters

  • value: number
  • Optional
    precision: number

Returns NumberExpectation & FinishedExpectation

`toBeCloseTo(4.0005, 4.0009, 3)` returns `true`, as there are 3
digits that are equal between actual and expected.
If no amount of digits is given, 5 is taken by default.

Answers if the actual value is defined (as in not equal to undefined)

Returns NumberExpectation & FinishedExpectation

Answers if the actual value is a falsy value.

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is greater than the expected value.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is greater than or equal than the expected value.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is infinity (positive or negative).

Returns NumberExpectation & FinishedExpectation

Answers if the actual value is the same as expected, using a deep compare mechanism. Do not use toBeLike with floating point numbers, use Expectations/Matchers.toBeCloseTo instead.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is lower than the expected value.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is lower than or equal than the expected value.

Parameters

  • value: number

Returns NumberExpectation & FinishedExpectation

Answer if the actual value is not a number.

Returns NumberExpectation & FinishedExpectation

Answers if the actual value is null (strict null, not undefined).

Returns NumberExpectation & FinishedExpectation

Answers if the actual value is a truthy value.

Returns NumberExpectation & FinishedExpectation

Answers if the actual value is undefined.

Returns NumberExpectation & FinishedExpectation

Answer if the actual element has the given shape, as defined by the shapeOf submodule.

Parameters

  • shape: Shape

Returns NumberExpectation & FinishedExpectation

Answers if the actual value has a type matching the expected type, checked by using the typeof operator.

Parameters

  • value: string

Returns NumberExpectation & FinishedExpectation

`toHaveType('hello', 'string')` returns `true`.