Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DelayedExpectation<Subject>

Type parameters

  • Subject

Hierarchy

Implements

Index

Constructors

constructor

  • new DelayedExpectation(entity: any, negate?: undefined | false | true): DelayedExpectation

Properties

Protected entity

entity: any

Protected Optional negate

negate: undefined | false | true

Accessors

not

Methods

apply

  • Pass subject to function, yielding result.

    example
      // apply square
      cyan.wrap(2+2).apply((x) => x*x).unwrap() // 16

    Type parameters

    • U

    Parameters

    • fn: (t: Subject) => U

      Function to invoke

        • (t: Subject): U
        • Parameters

          • t: Subject

          Returns U

    Returns Expectation<U>

each

  • each<T, U>(fn: (t: T) => U): Box<U[]>
  • Pass elements of (array-like) subject to function, yielding result.

    example
      // apply square
      cyan.wrap([1,2,3]).each((x) => x*x).unwrap() // [2,4,6]

    Type parameters

    • T

    • U

    Parameters

    • fn: (t: T) => U

      Function to invoke

        • (t: T): U
        • Parameters

          • t: T

          Returns U

    Returns Box<U[]>

Protected errorDescription

  • errorDescription(expected: string, actual: string, claim: string): string

expect

Protected fail

  • fail(expected: any, actual: any, message: string): void

filter

  • filter<T>(fn: (t: T) => boolean): Box<T[]>
  • Filter elements of (array-like) subject by predicate, yielding result.

    example
      // apply square
      cyan.wrap([1,2,3]).map((x) => x>2).unwrap() // [3]

    Type parameters

    • T

    Parameters

    • fn: (t: T) => boolean

      Function to invoke

        • (t: T): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns Box<T[]>

glom

  • glom<T, P1>(prop1: P1): Expectation<A<T>[P1]>
  • glom<T, P1, P2>(prop1: P1, prop2: P2): Expectation<A<A<T>[P1]>[P2]>
  • glom<T, P1, P2, P3>(prop1: P1, prop2: P2, prop3: P3): Expectation<A<A<A<T>[P1]>[P2]>[P3]>
  • glom(...path: string[]): Expectation<any>

invokes

  • invokes<K, F, R>(key: K, ...args: any[]): Box<R>
  • Yield the result of calling a named method on the subject.

    arg

    key {string} the method name

    Type parameters

    • K: keyof Subject

    • F: Method<Subject, K>

    • R

    Parameters

    • key: K
    • Rest ...args: any[]

    Returns Box<R>

Protected isTruthy

  • isTruthy(value: boolean): boolean

its

map

  • map<T, U>(fn: (t: T) => U): Box<U[]>
  • Pass elements of (array-like) subject to function, yielding result.

    example
      // apply square
      cyan.wrap([1,2,3]).map((x) => x*x).unwrap() // [2,4,6]

    Type parameters

    • T

    • U

    Parameters

    • fn: (t: T) => U

      Function to invoke

        • (t: T): U
        • Parameters

          • t: T

          Returns U

    Returns Box<U[]>

toBe

  • toBe<T>(expected: T): Promise<void>

unwrap

  • unwrap(): Subject
  • unwrap<Subject>(): never

wrap

  • wrap<T>(it: T): Box<T>
  • Yield an arbitrary subject.

    example
      // Open and shut
      cyan.wrap(2+2).unwrap() // => 4

    Type parameters

    • T

    Parameters

    • it: T

    Returns Box<T>

Static empty

  • empty(): Box<{}>
  • Build an empty box. Throw an error on yield if opened without wrapping anything else.

    Returns Box<{}>

Static with

  • with<U>(entity: U, negate?: undefined | false | true): Expectation<U>
  • with<U>(entity: Promise<U>, negate?: undefined | false | true): Expectation<U>

Generated using TypeDoc