Function assertRoute

  • Assert that a TStatebotFsm traced the route specified.

    Whereas routeIsPossible only checks that a particular route can be followed, assertRoute will hook-into a machine and wait for it to trace the specified path within a timeout period.

    Returns

    Example

    import { Statebot } from 'statebot'
    import { assertRoute } from 'statebot/assert'

    let machine = Statebot(...)

    assertRoute(
    machine, 'prepare -> debounce -> sending -> done -> idle',
    {
    description: 'Email sent with no issues',
    fromState: 'idle',
    timeoutInMs: 1000 * 20,
    permittedDeviations: 0,
    logLevel: 3
    }
    )
    .then(() => console.log('Assertion passed!'))
    .catch(err => console.error(`Whoops: ${err}`))

    machine.enter('idle')

    Parameters

    • machine: TStatebotFsm

      The machine to run the assertion on.

    • expectedRoute: string | string[]

      The expected route as an arrow-delimited string:

      "idle -> pending -> success -> done"

    • Optional options: TAssertRouteOptions

    Returns Promise<any>

Generated using TypeDoc