Skip to content

Commit

Permalink
test(splitAtom): moving first item to the end (#2238)
Browse files Browse the repository at this point in the history
When the `before` is unspecified for the first item, it is being moved to the end of the list.

Co-authored-by: Daishi Kato <[email protected]>
  • Loading branch information
MiroslavPetrik and dai-shi authored Nov 6, 2023
1 parent 87ddf5e commit f5691b5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/react/vanilla-utils/splitAtom.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ it('moving atoms', async () => {
<TaskItem
key={`${anAtom}`}
onMoveLeft={() => {
if (index > 0) {
if (index === 0) {
dispatch({
type: 'move',
atom: anAtom,
})
} else if (index > 0) {
dispatch({
type: 'move',
atom: anAtom,
Expand Down Expand Up @@ -372,6 +377,13 @@ it('moving atoms', async () => {
'help nana<>get dragon food<>get cat food<>'
)
})

fireEvent.click(getByTestId('help nana-leftbutton'))
await waitFor(() => {
expect(queryByTestId('list')?.textContent).toBe(
'get dragon food<>get cat food<>help nana<>'
)
})
})

it('read-only array atom', async () => {
Expand Down

1 comment on commit f5691b5

@vercel
Copy link

@vercel vercel bot commented on f5691b5 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.