How to use the xstate/lib/graph.getShortestPaths function in xstate

To help you get started, we’ve selected a few xstate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MicheleBertoli / react-automata / src / testStateMachine.js View on Github external
const testStateMachine = (Component, options = {}) => {
  const paths = getShortestPaths(Component.machine, options.extendedState)

  Object.keys(paths).forEach(key => {
    const initialData = idx(options, _ => _.fixtures.initialData)
    const renderer = TestRenderer.create(
      
    )
    const instance = renderer.getInstance()

    paths[key].forEach(({ event, state }) => {
      const fixtures = idx(options, _ => _.fixtures[state][event])

      instance.handleTransition(event, fixtures)
    })

    const machineState =
      instance.state.machineState.toString() ||