Created
May 5, 2021 11:01
-
-
Save jf423/989b58eabbd0d2401235ef48ee2ac390 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LevelItemMachine = Machine({ | |
id: 'LevelItem', | |
initial: 'default', | |
states: { | |
default: { | |
on: { | |
RERENDER_EMPTY: 'empty', | |
RERENDER_SUCCESS: 'success', | |
}, | |
meta: { | |
test: ({ getByTestId }) => { | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM.ID)).toBeInTheDocument() | |
}, | |
}, | |
}, | |
empty: { | |
meta: { | |
test: ({ getByTestId }) => { | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM.ID)).toBeInTheDocument() | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM_ICON.ID)).toBeInTheDocument() | |
}, | |
}, | |
}, | |
success: { | |
initial: 'complete', | |
states: { | |
complete: { | |
meta: { | |
test: ({ getByTestId }) => { | |
const LevelItemIndex = 0 | |
const { | |
data: { level }, | |
} = GET_USER_LEVEL | |
const { satisfy_img: complete } = level[LevelItemIndex] | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM_ICON.ID)).toHaveAttribute('src', complete) | |
}, | |
}, | |
}, | |
incomplete: { | |
meta: { | |
test: ({ getByTestId }) => { | |
const LevelItemIndex = 0 | |
const { | |
data: { level }, | |
} = GET_USER_LEVEL | |
const { not_satisfy_img: incomplete } = level[LevelItemIndex] | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM_ICON.ID)).toHaveAttribute('src', incomplete) | |
}, | |
}, | |
}, | |
}, | |
on: { | |
RERENDER_SUCCESS_WITH_COMPLETE: 'success.complete', | |
RERENDER_SUCCESS_WITH_INCOMPLETE: 'success.incomplete', | |
}, | |
meta: { | |
test: ({ getByTestId }) => { | |
const LevelItemIndex = 0 | |
const { | |
data: { level: totalLevel }, | |
} = GET_USER_LEVEL | |
const { badge_name: name, title } = totalLevel[LevelItemIndex] | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM_RANK.ID)).toHaveTextContent(title) | |
expect(getByTestId(LEVEL_CAROUSEL_ITEM_NAME.ID)).toHaveTextContent(name) | |
}, | |
}, | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment