Options
All
  • Public
  • Public/Protected
  • All
Menu

Environment provides a space for tracking ambient links.

Hierarchy

  • Environment

Index

Properties

Private activeSpec

activeSpec: Specification

Private links

links: Container<any>[] = []

Private logHistory

logHistory: string[] = []

Private specs

specs: Specification[] = []

Accessors

output

Methods

describe

  • describe(featureName: string, theSpec: () => void): void
  • Parameters

    • featureName: string
    • theSpec: () => void
        • (): void
        • Returns void

    Returns void

expect

  • Assert an expectation on the yielded value.

    example
      // Simple expect
      cyr.wrap(2+2).expect().toBe(4)
    
      // Pluck `my.value` from the wrapped subject
      cyr.wrap({ my: { value: 'here' }}).expect('my').its('value').toBe('here')

    Type parameters

    • T

    Parameters

    • value: Promise<T>

    Returns Expectation<T>

  • Type parameters

    • T

    Parameters

    • value: T

    Returns Expectation<T>

Protected handleLink

  • handleLink<T>(link: Container<T>): Promise<void>

Protected handleSpec

Protected handleTestCase

  • handleTestCase(testCase: TestCase): Promise<void>

it

  • it(behaviorName: string, theTestCase: () => void): void
  • Parameters

    • behaviorName: string
    • theTestCase: () => void
        • (): void
        • Returns void

    Returns void

link

  • Manually add a monadic link expectation to this environment.

    Parameters

    • expectation: Expectation<any>

      the expectation to link

    Returns void

log

  • log(message: string): void
  • Output a message to the log.

    Parameters

    • message: string

      value to write

    Returns void

Private logSync

  • logSync(message: string): void

processAmbient

  • processAmbient(): Promise<void>
  • Analyze the ambient environment (gathering any model specifications)

    Returns Promise<void>

Private processLink

  • processLink<T>(link: Container<T>): Promise<void>

reset

  • reset(): void
  • Factory-reset this environment (purge all commands, links, log output)

    Returns void

verify

  • verify(): Promise<void>

verifyAmbient

  • verifyAmbient(): Promise<void>
  • Verify all ambient links in this environment.

    example
      cyr.expect(2+2).toBe(4)
      await cyr.verifyAmbient() // ✓ okay
    
      cyr.expect(2+2).toBe(5)
      await cyr.verifyAmbient() // ✕ throws

    Returns Promise<void>

verifySpecs

  • verifySpecs(): Promise<void>
  • Verify all specs in this environment.

    example
      cyr.describe('2+2', () => cyr.its('4', () => expect(2+2).toBe(4)))
      await cyr.verifySpecs() //2+2 -> 4
    
      cyr.describe('2+2', () => cyr.its('5', () => expect(2+2).toBe(5)))
      await cyr.verifySpecs() //2+2 -> 5

    Returns Promise<void>

wrap

  • wrap<T>(arg: T): Box<T>
  • wrap<U, T>(arg: T): Box<U>
  • Yield the given value.

    example
      // Simple wrap
      cyr.wrap(2+2).expect().toBe(4)
    
      // Pluck `env.user` from the wrapped subject
      cyr.wrap(process).expect('env').its('user').toBe(process.env.user)

    Type parameters

    • T

    Parameters

    • arg: T

    Returns Box<T>

  • Type parameters

    Parameters

    • arg: T

    Returns Box<U>

Generated using TypeDoc