How to use the @xstate/graph.getSimplePaths function in @xstate/graph

To help you get started, we’ve selected a few @xstate/graph 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 johnkazer / hyperapp-xstate-demo / cypress / integration / tests.js View on Github external
/// 
import { videoMachine, audioMachine } from '../../src/machines.js'
import { getSimplePaths, getShortestPaths } from '@xstate/graph'
import { map, compose, pipe, lensPath, view, curry } from 'ramda'

const videoSimplePaths = getSimplePaths(videoMachine)
const audioSimplePaths = getSimplePaths(audioMachine)
const videoShortestPaths = getShortestPaths(videoMachine)
const audioShortestPaths = getShortestPaths(audioMachine)

const videoStateList = Object.keys(videoSimplePaths)
const audioStateList = Object.keys(audioSimplePaths)
const machineName = lensPath(['tree', 'stateNode', 'config', 'id'])
const currentMachine = (state) => view(machineName, state) === 'videoMachine' ? videoMachine : audioMachine
const selectSimpleVideoPaths = (currentState) => videoSimplePaths[currentState].paths[0]
const selectSimpleAudioPaths = (currentState) => audioSimplePaths[currentState].paths[0]
const reload = () => cy.reload()
const appIsReady = () => cy.get('video').should('be.visible')
const changeTab = (newTab) => () => cy.get(`button[id="${newTab}"`).click()
const changeToAudioTab = changeTab('audioTab')
const checkTransition = ({ state, event }) => {
	cy.log(`checking transition from ${state.value} due to ${event.type}`)
	// if there are paths[x].state.actions[y] then have Hyperapp and XState run the action(s) for us
github johnkazer / hyperapp-xstate-demo / cypress / integration / tests.js View on Github external
/// 
import { videoMachine, audioMachine } from '../../src/machines.js'
import { getSimplePaths, getShortestPaths } from '@xstate/graph'
import { map, compose, pipe, lensPath, view, curry } from 'ramda'

const videoSimplePaths = getSimplePaths(videoMachine)
const audioSimplePaths = getSimplePaths(audioMachine)
const videoShortestPaths = getShortestPaths(videoMachine)
const audioShortestPaths = getShortestPaths(audioMachine)

const videoStateList = Object.keys(videoSimplePaths)
const audioStateList = Object.keys(audioSimplePaths)
const machineName = lensPath(['tree', 'stateNode', 'config', 'id'])
const currentMachine = (state) => view(machineName, state) === 'videoMachine' ? videoMachine : audioMachine
const selectSimpleVideoPaths = (currentState) => videoSimplePaths[currentState].paths[0]
const selectSimpleAudioPaths = (currentState) => audioSimplePaths[currentState].paths[0]
const reload = () => cy.reload()
const appIsReady = () => cy.get('video').should('be.visible')
const changeTab = (newTab) => () => cy.get(`button[id="${newTab}"`).click()
const changeToAudioTab = changeTab('audioTab')
const checkTransition = ({ state, event }) => {
	cy.log(`checking transition from ${state.value} due to ${event.type}`)
github davidkpiano / xstate / packages / xstate-test / src / index.ts View on Github external
public getSimplePathPlans(
    options?: Partial>
  ): Array> {
    const simplePaths = getSimplePaths(this.machine, {
      ...options,
      events: getEventSamples(this.options.events)
    }) as StatePathsMap;

    return this.getTestPlans(simplePaths);
  }

@xstate/graph

XState graph utilities

MIT
Latest version published 2 years ago

Package Health Score

78 / 100
Full package analysis