Skip to content

Instantly share code, notes, and snippets.

@jf423
Created April 21, 2021 02:16
Show Gist options
  • Save jf423/523429893f75ff703e8dd25f4a639c65 to your computer and use it in GitHub Desktop.
Save jf423/523429893f75ff703e8dd25f4a639c65 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const walletMachine = Machine({
id: 'Wallet',
initial: 'default',
states: {
default: {
initial: 'initial',
states: {
initial: {
meta: {
test: ({ getByTestId }) => {
expect(getByTestId(WALLET_TOTAL_CURRENCY.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_CASHOUT_BUTTON.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_WEEK_CURRENCY.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_AMOUNT_CURRENCY.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_CONTACT.ID)).toBeInTheDocument()
},
},
},
cashOut: {
meta: {
test: () => {
expect(onCashOut).toBeCalled()
},
},
},
},
on: {
CLICK_CASH_OUT: 'default.cashOut',
RERENDER_EMPTY: 'empty',
},
meta: {
test: ({ getByTestId }) => {
expect(getByTestId(WALLET_CONTAINER.ID)).toBeInTheDocument()
},
},
},
empty: {
on: {
RERENDER_SUCCESS: 'success',
},
meta: {
test: ({ getByTestId }) => {
expect(getByTestId(WALLET_CONTAINER.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_CASHOUT_BUTTON.ID)).toBeInTheDocument()
expect(getByTestId(WALLET_CONTACT.ID)).toBeInTheDocument()
},
},
},
success: {
meta: {
test: ({ getByTestId }) => {
const { current, week, progressive } = DATA.GET_USER_WALLET
expect(getByTestId(WALLET_TOTAL_CURRENCY.ID)).toHaveTextContent(current)
expect(getByTestId(WALLET_WEEK_CURRENCY.ID)).toHaveTextContent(week)
expect(getByTestId(WALLET_AMOUNT_CURRENCY.ID)).toHaveTextContent(progressive)
},
},
},
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment