import { Assertion } from "./Assertion"; export interface BaseBetweenOptions { range: [number, number]; } export interface CloseToOptions { value: number; withOffset: number; } export interface InclusiveBetweenOptions extends BaseBetweenOptions { inclusive: boolean; } export interface LowInclusiveBetweenOptions extends BaseBetweenOptions { lowInclusive: boolean; } export interface HighInclusiveBetweenOptions extends BaseBetweenOptions { highInclusive: boolean; } export type BetweenOptions = BaseBetweenOptions | InclusiveBetweenOptions | LowInclusiveBetweenOptions | HighInclusiveBetweenOptions; /** * Encapsulates assertion methods applicable to values of type number */ export declare class NumberAssertion extends Assertion { constructor(actual: number); /** * Check if the number is zero. * * @example * ``` * expect(0).toBeZero(); * ``` * * @returns the assertion instance */ toBeZero(): this; /** * Check if the number is positive. That is, when the number is greater than * zero. * * @example * ``` * expect(10).toBePositive(); * ``` * * @returns the assertion instance */ toBePositive(): this; /** * Check if the number is negative. That is, when the number is less than * zero. * * @example * ``` * expect(-10).toBeNegative(); * ``` * * @returns the assertion instance */ toBeNegative(): this; /** * Check if the number is finite. That is, when the number is not a * JavaScript's `Infinity` value. Keep in mind that this includes * positive and negative infinity. * * @example * ``` * expect(0).toBeFinite(); * expect(-10).toBeFinite(); * expect(10).toBeFinite(); * ``` * * @returns the assertion instance */ toBeFinite(): this; /** * Check if the number is `NaN`. That is only when the number is JavaScript's * `NaN` value. * * @example * ``` * expect(NaN).toBeNaN(); * expect(0/0).toBeNaN(); * ``` * * @returns the assertion instance */ toBeNaN(): this; /** * Check if the number is even. That is, when the number is divisible by 2. * * @example * ``` * expect(50).toBeEven(); * expect(0).toBeEven(); * expect(-10).toBeEven(); * ``` * * @returns the assertion instance */ toBeEven(): this; /** * Check if the number is odd. That is, when the number is not divisible by 2. * * @example * ``` * expect(-13).toBeOdd(); * expect(17).toBeOdd(); * ``` * * @returns the assertion instance */ toBeOdd(): this; /** * Check if the number is between the specified bounds. By default, the * bounds are exclusive, but the options allow to set the high, low, or both * limits as inclusive * * @example * ``` * expect(0).toBeBetween({ * range: [-1, 1], * }); * * expect(-1).toBeBetween({ * range: [-1, 1], * lowInclusive: true, * }); * * expect(1).toBeBetween({ * range: [-1, 1], * highInclusive: true, * }); * * expect(0).toBeBetween({ * range: [0, 0], * inclusive: true, * }); * ``` * * @param options an object of type {@link BetweenOptions} where the `range` * property defines the bounds, so it's always required. Use * `inclusive: true` to make both limits inclusive. Or you can * selectively make low or high limits inclusive using * `lowInclusive: true` or `highInclusive: true`, respectively * @returns the assertion instance */ toBeBetween(options: BetweenOptions): this; /** * Check if the number value is close to the base value with certain offset. * This checks both limits min and max which are inclusive. * * @example * ``` * expect(-1).toBeCloseTo({ * value: 0, * withOffset: 1, * }); * * expect(1).toBeCloseTo({ * value: 0, * withOffset: 1, * }); * ``` * * @param options the object that contains the value (base number that value * should be close) and withOffset (min and max offset value) * * @returns the assertion instance */ toBeCloseTo(options: CloseToOptions): this; /** * Check if the number value is greater than the defined value. * * @example * ``` * expect(5).toBeGreaterThan(3); * ``` * * @param value the value that number should be greater than * @returns the assertion instance */ toBeGreaterThan(value: number): this; /** * Check if the number value is greater than or equal to the defined value. * * @example * ``` * expect(5).toBeGreaterThanOrEqual(3); * expect(3).toBeGreaterThanOrEqual(3); * ``` * * @param value the value that number should be greater than or equal to * @returns the assertion instance */ toBeGreaterThanOrEqual(value: number): this; /** * Check if the number value is less than the defined value. * * @example * ``` * expect(2).toBeLessThan(5); * ``` * * @example * @param value the value that number should be less than * @returns the assertion instance */ toBeLessThan(value: number): this; /** * Check if the number value is less than or equal to the defined value. * * @example * ``` * expect(2).toBeLessThanOrEqual(5); * expect(5).toBeLessThanOrEqual(5); * ``` * * @param value the value that number should be less than or equal to * @returns the assertion instance */ toBeLessThanOrEqual(value: number): this; }